<?php

declare(strict_types=1);

namespace Gls\GlsPoland\PrestaShop\Hook\Front;

use Gls\GlsPoland\Configuration\Initializer\ConfigurationInitializerInterface;
use Gls\GlsPoland\PrestaShop\Hook\AliasedHookInterface;
use Gls\GlsPoland\PrestaShop\Hook\VersionRange;

final class ActionFrontControllerInitAfter implements AliasedHookInterface
{
    public const HOOK_NAME = 'actionFrontControllerInitAfter';
    private const HOOK_ALIAS = 'actionFrontControllerAfterInit';

    private $initializers;

    /**
     * @param iterable<ConfigurationInitializerInterface> $initializers
     */
    public function __construct(iterable $initializers)
    {
        $this->initializers = $initializers;
    }

    public static function getAliases(): array
    {
        return [
            self::HOOK_ALIAS => new VersionRange(null, '1.7.7'),
            self::HOOK_NAME => new VersionRange('1.7.7'),
        ];
    }

    public function execute(array $parameters): void
    {
        foreach ($this->initializers as $initializer) {
            $initializer->init();
        }
    }
}
