src/Controller/Website/CatalogController.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Controller\Website;
  3. use App\Facade\ProductFamilyFacade;
  4. use App\Utils\SchemaManager;
  5. use Spatie\SchemaOrg\Schema;
  6. use Sulu\Component\Content\Compat\StructureInterface;
  7. use App\Repository\ProductCategoryRepository;
  8. use Symfony\Component\HttpFoundation\Response;
  9. class CatalogController extends SuluExtendController
  10. {
  11.     public function viewAction(
  12.         ProductCategoryRepository   $productCategoryRepository,
  13.         ProductFamilyFacade         $productFamilyFacade,
  14.         StructureInterface          $structure,
  15.         SchemaManager               $schemaManager,
  16.                                     $attributes = [],
  17.                                     $preview false,
  18.                                     $partial false,
  19.     ): Response
  20.     {
  21.         $attributes $this->getAttributes([], $structure);
  22.         $attributes['breadcrumbs'] = $this->getBreadcrumbs('page'$attributes['uuid']);
  23.         // ---------------------------------------
  24.         // Header
  25.         // ---------------------------------------
  26.         $attributes['catalog_section'] = [
  27.             'header' => [
  28.                 'heading' => [
  29.                     'title' => $attributes['content']['title'],
  30.                 ],
  31.             ],
  32.             'spacing' => 'top-0'
  33.         ];
  34.         // ---------------------------------------
  35.         // Categories
  36.         // ---------------------------------------
  37.         $attributes['categories_section'] = [
  38.             'header' => [
  39.                 'heading' => [
  40.                     'title' => 'Kategorie',
  41.                     'style' => 'h3',
  42.                     'decoration_after' => true,
  43.                 ],
  44.             ],
  45.             'spacing' => 'top-0'
  46.         ];
  47.         $attributes['categories_section']['group']['items'] = $productCategoryRepository->getCategories();
  48.         // ---------------------------------------
  49.         // Families
  50.         // ---------------------------------------
  51.         $attributes['categories_families_section'] = [
  52.             'header' => [
  53.                 'heading' => [
  54.                     'title' => 'Rodiny',
  55.                     'style' => 'h3',
  56.                     'decoration_after' => true,
  57.                 ],
  58.             ],
  59.             'spacing' => 'top-0'
  60.         ];
  61.         $attributes['categories_families_section']['group']['items'] = $productFamilyFacade->renderProductFamilies();
  62.         $schema $schemaManager->getDefaultSchemas($attributes['breadcrumbs']);
  63.         $schemaItemList Schema::itemList()
  64.             ->name($attributes['content']['title'])
  65.             ->description($attributes['content']['description']);
  66.         $schema[] = $schemaItemList;
  67.         $attributes['_schema'] = implode(''$schema);
  68.         
  69.         return $this->renderAll('pages/catalog.html.twig'$attributes$preview$partial);
  70.     }
  71. }