<?php
namespace App\ViewProcessor;
use App\Entity\CategoryOptions;
use Boldr\Shop\ShopBundle\Entity\Category;
use Boldr\Shop\ShopBundle\Presenter\Category\CategoryViewProcessorInterface;
use Boldr\Shop\ShopBundle\Presenter\Category\CategoryView;
use Doctrine\ORM\EntityManagerInterface;
class CategoryViewProcessor implements CategoryViewProcessorInterface
{
private EntityManagerInterface $em;
public function __construct(EntityManagerInterface $em)
{
$this->em = $em;
}
public function processCategoryView(CategoryView $categoryView, Category $category, string $locale): CategoryView
{
$options = $this->em->getRepository(CategoryOptions::class)->find($category);
if ($options !== null)
{
$categoryView->hbVisibleInExtras = $options->getVisibleInExtras();
$categoryView->hbShowExtras = $options->getShowExtras();
}
else
{
$categoryView->hbVisibleInExtras = false;
$categoryView->hbShowExtras = false;
}
return $categoryView;
}
}