src/ViewProcessor/CategoryViewProcessor.php line 21

Open in your IDE?
  1. <?php
  2. namespace App\ViewProcessor;
  3. use App\Entity\CategoryOptions;
  4. use Boldr\Shop\ShopBundle\Entity\Category;
  5. use Boldr\Shop\ShopBundle\Presenter\Category\CategoryViewProcessorInterface;
  6. use Boldr\Shop\ShopBundle\Presenter\Category\CategoryView;
  7. use Doctrine\ORM\EntityManagerInterface;
  8. class CategoryViewProcessor implements CategoryViewProcessorInterface
  9. {
  10.     private EntityManagerInterface $em;
  11.     public function __construct(EntityManagerInterface $em)
  12.     {
  13.         $this->em $em;
  14.     }
  15.     public function processCategoryView(CategoryView $categoryViewCategory $categorystring $locale): CategoryView
  16.     {
  17.         $options $this->em->getRepository(CategoryOptions::class)->find($category);
  18.         if ($options !== null)
  19.         {
  20.             $categoryView->hbVisibleInExtras $options->getVisibleInExtras();
  21.             $categoryView->hbShowExtras $options->getShowExtras();
  22.         }
  23.         else
  24.         {
  25.             $categoryView->hbVisibleInExtras false;
  26.             $categoryView->hbShowExtras false;
  27.         }
  28.         return $categoryView;
  29.     }
  30. }