<?php

namespace WeDevs\AppBridge\Integrations\WPERP;

use WeDevs\AppBridge\Core\AbstractIntegration;
use WeDevs\AppBridge\Core\Contracts\Hookable;
use WeDevs\AppBridge\Integrations\WPERP\REST\AppConfigController;
use WeDevs\AppBridge\Integrations\WPERP\REST\AttestController;
use WeDevs\AppBridge\Integrations\WPERP\REST\LicenseController;
use WeDevs\AppBridge\Integrations\WPERP\REST\SettingsController;

class WPERPIntegration extends AbstractIntegration {

	private LicenseManager $license_manager;

	public function __construct() {
		$this->license_manager = new LicenseManager();
	}

	public function get_license_manager(): LicenseManager {
		return $this->license_manager;
	}

	public static function is_active(): bool {
		return class_exists( 'WeDevs\ERP\Framework\ERP' ) || defined( 'WPERP_VERSION' );
	}

	public function hookables(): array {
		return [
			$this->license_manager,
		];
	}

	public function rest_controllers(): array {
		return [
			new SettingsController(),
			new LicenseController( $this->license_manager ),
			new AppConfigController(),
			new AttestController( $this->license_manager ),
		];
	}

	public function menus(): array {
		return [
			[
				'label'    => __( 'WP ERP', 'app-bridge' ),
				'slug'     => 'app-bridge-wp-erp',
				'mount_id' => 'app-bridge-wp-erp',
			],
		];
	}
}
