<?php
/**
 * AdminInitHook class.
 *
 * Initializes admin-related settings handlers on the 'admin_init' hook.
 *
 * @package Ilabs\Firevert\Core\Hooks\Admin
 */

declare( strict_types=1 );

namespace Ilabs\Firevert\Core\Hooks\Admin;

use Ilabs\Firevert\Core\Settings\Form\SettingsFormHandler;
use Ilabs\Firevert\Core\Settings\Registrar\SettingsApiRegistrar;

/**
 * Class AdminInitHook
 *
 * Loads settings form and settings API logic during admin_init.
 */
class AdminInitHook {

	/**
	 * Registers WordPress hooks.
	 */
	public function register(): void {
		add_action( 'admin_init', array( $this, 'on_admin_init' ), 10 );
	}

	/**
	 * Callback for the 'admin_init' action.
	 * Loads and registers services from the container.
	 */
	public function on_admin_init(): void {
		/**
		 * Get from DI container.
		 *
		 * @var SettingsFormHandler $settings_form_handler
		 */
		$settings_form_handler = firevert_container()->get( 'settings_form_handler' );
		$settings_form_handler->register();

		/**
		 * Get from DI container.
		 *
		 * @var SettingsApiRegistrar $settings_api_registrar
		 */
		$settings_api_registrar = firevert_container()->get( 'settings_api_registrar' );
		$settings_api_registrar->register();
	}
}
