<?php
namespace App\Controller\Website;
use App\Utils\SchemaManager;
use Sulu\Component\Content\Compat\StructureInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Response;
class BlockController extends SuluExtendController
{
public function viewAction(
StructureInterface $structure,
SchemaManager $schemaManager,
$attributes = [],
$preview = false,
$partial = false,
): Response
{
$attributes = $this->getAttributes([], $structure);
$attributes['breadcrumbs'] = $this->getBreadcrumbs('page', $attributes['uuid']);
$schema = $schemaManager->getDefaultSchemas( $attributes['breadcrumbs']);
if(isset($attributes['content']['blocks'])) {
$blockList = $this->resolveBlocks($attributes['content']['blocks'], $schema);
if($blockList instanceof RedirectResponse) {
return $blockList;
}
$attributes['content']['blocks'] = $blockList->getBlocks();
$schema = $blockList->getSchema();
}
$attributes['_schema'] = implode('', $schema);
return $this->renderAll('pages/blocks.html.twig', $attributes, $preview, $partial);
}
}