* @copyright Since 2007 PrestaShop SA and Contributors * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ declare(strict_types=1); namespace PrestaShop\PrestaShop\Adapter\Hook\QueryHandler; use Hook; use PrestaShop\PrestaShop\Core\Domain\Hook\Exception\HookNotFoundException; use PrestaShop\PrestaShop\Core\Domain\Hook\Query\GetHookStatus; use PrestaShop\PrestaShop\Core\Domain\Hook\QueryHandler\GetHookStatusHandlerInterface; /** * @internal */ final class GetHookStatusHandler implements GetHookStatusHandlerInterface { /** * {@inheritdoc} */ public function handle(GetHookStatus $query) { $hookId = $query->getHookId()->getValue(); $hook = new Hook($hookId); if ($hook->id !== $hookId) { throw new HookNotFoundException(sprintf('Hook with id "%d" was not found.', $hookId)); } return (bool) $hook->active; } }