<?php
/**
 * Handles the instance of the Northmill Online Shared code.
 *
 * @package flo-checkout
 *
 * @phpcs:disable Squiz.Commenting.FunctionComment.MissingParamTag
 */

namespace Flo_Checkout;

use Flo_Checkout\Admin\Pages\Admin_Status_Page;
use Northmill_Online_Shared_Checkout\Northmill_Online_Shared\Abstract_Plugin_Shared;
use Northmill_Online_Shared_Checkout\Northmill_Online_Shared\Modules\Loggers\Log_Level_Enum;
use Northmill_Online_Shared_Checkout\Northmill_Online_Shared\Traits\Singleton_Trait;

defined( 'ABSPATH' ) || exit;

/**
 * Class Shared
 */
class Shared extends Abstract_Plugin_Shared {
	use Singleton_Trait;

	/**
	 * {@inheritDoc}
	 */
	protected function setup_hooks( string $service_name_underscored ): void {
		// Register the banner URLs.
		add_filter(
			'northmill_online_shared_banner_urls_' . $service_name_underscored,
			function () {
				return array(
					'high' => 'https://downloadsflo.northmill.com/wp-content/uploads/2017/04/moreflo-system-1024x532.png',
				);
			},
		);

		// Register the package info URL.
		add_filter(
			'northmill_online_shared_package_info_json_url_' . $service_name_underscored,
			function () {
				return 'https://downloadsflo.northmill.com/plugin/flo-checkout.json';
			},
		);

		// Hide the cleaner section on the Tools page. // TODO: Implement the cleaner?
		add_filter(
			'northmill_online_shared_tools_show_uninstall_cleaner_section_' . $service_name_underscored,
			'__return_false',
		);

		// Add action for post-Shared setup.
		add_action(
			'northmill_online_shared_after_setup_' . $service_name_underscored,
			array( $this, 'post_successful_setup' )
		);

		Admin_Status_Page::setup_shared_hooks( $service_name_underscored );
		Cron::setup_shared_hooks( $service_name_underscored );
		Plugin_Upgrade::setup_shared_hooks( $service_name_underscored );
	}

	/**
	 * {@inheritDoc}
	 */
	public function get_package_file_path(): string {
		return FLO_CHECKOUT_ABS_FILE_PATH;
	}

	/**
	 * {@inheritDoc}
	 */
	public function get_translations(): array {
		return array(
			'flo-checkout-plugin',
			'woocommerce-gateway-credorax',
		);
	}

	/**
	 * Run on successful Shared setup.
	 */
	public function post_successful_setup(): void {
		$this->logger->set_settings_log_level( Log_Level_Enum::DEBUG );

		Assets::setup();
		REST_API::instance();
		Gateways::setup();
		Orders::setup();
		Users::setup();
	}
}
