<?php
namespace App\Controller\Website;
use App\Facade\ProductFamilyFacade;
use App\Utils\SchemaManager;
use Spatie\SchemaOrg\Schema;
use Sulu\Component\Content\Compat\StructureInterface;
use App\Repository\ProductCategoryRepository;
use Symfony\Component\HttpFoundation\Response;
class CatalogController extends SuluExtendController
{
public function viewAction(
ProductCategoryRepository $productCategoryRepository,
ProductFamilyFacade $productFamilyFacade,
StructureInterface $structure,
SchemaManager $schemaManager,
$attributes = [],
$preview = false,
$partial = false,
): Response
{
$attributes = $this->getAttributes([], $structure);
$attributes['breadcrumbs'] = $this->getBreadcrumbs('page', $attributes['uuid']);
// ---------------------------------------
// Header
// ---------------------------------------
$attributes['catalog_section'] = [
'header' => [
'heading' => [
'title' => $attributes['content']['title'],
],
],
'spacing' => 'top-0'
];
// ---------------------------------------
// Categories
// ---------------------------------------
$attributes['categories_section'] = [
'header' => [
'heading' => [
'title' => 'Kategorie',
'style' => 'h3',
'decoration_after' => true,
],
],
'spacing' => 'top-0'
];
$attributes['categories_section']['group']['items'] = $productCategoryRepository->getCategories();
// ---------------------------------------
// Families
// ---------------------------------------
$attributes['categories_families_section'] = [
'header' => [
'heading' => [
'title' => 'Rodiny',
'style' => 'h3',
'decoration_after' => true,
],
],
'spacing' => 'top-0'
];
$attributes['categories_families_section']['group']['items'] = $productFamilyFacade->renderProductFamilies();
$schema = $schemaManager->getDefaultSchemas($attributes['breadcrumbs']);
$schemaItemList = Schema::itemList()
->name($attributes['content']['title'])
->description($attributes['content']['description']);
$schema[] = $schemaItemList;
$attributes['_schema'] = implode('', $schema);
return $this->renderAll('pages/catalog.html.twig', $attributes, $preview, $partial);
}
}