<?php
/**
 * CoreSettingsRegistrar class.
 *
 * Registers core settings groups used in the Firevert admin panel.
 *
 * @package Ilabs\Firevert\Core\Settings\Registrar
 */

declare( strict_types=1 );

namespace Ilabs\Firevert\Core\Settings\Registrar;

use Ilabs\Firevert\Core\Settings\Registry\SettingsRegistry;

/**
 * Registers system-level settings groups: modules, general, support.
 */
final class CoreSettingsRegistrar {

	public const GROUP_MODULES  = 'modules';
	public const GROUP_GENERAL  = 'general';
	public const GROUP_SUPPORT  = 'support';
	public const GROUP_SERVICES = 'partners_and_services';

	/**
	 * Central registry for settings group definitions.
	 *
	 * @var SettingsRegistry
	 */
	private SettingsRegistry $registry;

	/**
	 * Constructor.
	 *
	 * @param SettingsRegistry $registry Get from DI container.
	 */
	public function __construct( SettingsRegistry $registry ) {
		$this->registry = $registry;
	}

	/**
	 * Registers all system setting groups.
	 *
	 * @return void
	 */
	public function register(): void {
		$this->register_modules_group();
		$this->register_general_group();
		$this->register_support_group();
		$this->register_partners_and_services_group();
	}

	/**
	 * Registers the 'modules' group with a checkbox per module.
	 *
	 * @return void
	 */
	private function register_modules_group(): void {
		$this->registry->register_group(
			self::GROUP_MODULES,
			array(
				'title'       => __( 'Modules', 'firevert' ),
				'description' => __( 'Enable or disable available modules.', 'firevert' ),
				'has_form'    => false,
				'is_module'   => false,
				'fields'      => array(),
			)
		);
	}

	/**
	 * Registers the 'general' group.
	 *
	 * @return void
	 */
	private function register_general_group(): void {
		$this->registry->register_group(
			self::GROUP_GENERAL,
			array(
				'title'       => __( 'General Settings', 'firevert' ),
				'description' => __( 'Global plugin configuration.', 'firevert' ),
				'is_module'   => false,
				'has_form'    => false,
				'fields'      => array(),
			)
		);
	}

	/**
	 * Registers the 'support' group.
	 *
	 * @return void
	 */
	private function register_support_group(): void {
		$this->registry->register_group(
			self::GROUP_SUPPORT,
			array(
				'title'       => __( 'Support', 'firevert' ),
				'description' => __( 'Contact with our Firevert support team.', 'firevert' ),
				'is_module'   => false,
				'has_form'    => false,
				'custom_view' => 'support.view.php',
				'fields'      => array(),
			)
		);
	}

	/**
	 * Registers the 'partners and services' group.
	 *
	 * @return void
	 */
	private function register_partners_and_services_group(): void {
		$this->registry->register_group(
			self::GROUP_SERVICES,
			array(
				'title'       => __( 'Partners and services', 'firevert' ),
				'description' => __( 'Information about official Firevert partners and available services.', 'firevert' ),
				'is_module'   => false,
				'has_form'    => false,
				'custom_view' => 'partners-and-services.view.php',
				'fields'      => array(),
			)
		);
	}
}
