* @copyright Since 2007 PrestaShop SA and Contributors * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\PrestaShop\Adapter\Category\QueryHandler; use Category; use PrestaShop\PrestaShop\Core\Domain\Category\Exception\CategoryNotFoundException; use PrestaShop\PrestaShop\Core\Domain\Category\Query\GetCategoryIsEnabled; use PrestaShop\PrestaShop\Core\Domain\Category\QueryHandler\GetCategoryIsEnabledHandlerInterface; /** * @internal */ final class GetCategoryIsEnabledHandler implements GetCategoryIsEnabledHandlerInterface { /** * {@inheritdoc} */ public function handle(GetCategoryIsEnabled $query) { $categoryId = $query->getCategoryId()->getValue(); $category = new Category($categoryId); if ($category->id !== $categoryId) { throw new CategoryNotFoundException($query->getCategoryId(), sprintf('Category with id "%s" was not found.', $categoryId)); } return (bool) $category->active; } }