<?php

declare(strict_types=1);

class Dispatcher extends DispatcherCore
{
    /**
     * @throws PrestaShopException
     */
    public function dispatch(): void
    {
        $headers = getallheaders();

        header('Access-Control-Allow-Origin: ' . ($headers['origin'] ?? '*'));
        header('Access-Control-Allow-Methods: GET, POST, DELETE, PUT');
        header('Access-Control-Allow-Headers: X-Requested-With, Content-Type, Authorization, Origin, Accept');
        header('Access-Control-Allow-Credentials: true');
        if ('OPTIONS' != $_SERVER['REQUEST_METHOD']) {
            parent::dispatch();
        }
    }
}
