#[Route(path: 'api/app-system/cms/blocks', name: 'api.app_system.cms.blocks', methods: ['GET'])]
public function getBlocks(Context
$context): Response
{ $criteria =
new Criteria();
$criteria ->
addFilter(new EqualsFilter('app.active', true
)) ->
addSorting(new FieldSorting('name'
));
/** @var AppCmsBlockCollection $blocks */
$blocks =
$this->cmsBlockRepository->
search($criteria,
$context)->
getEntities();
return new JsonResponse(['blocks' =>
$this->
formatBlocks($blocks)]);
} private function formatBlocks(AppCmsBlockCollection
$blocks): array
{ $formattedBlocks =
[];
/** @var AppCmsBlockEntity $block */
foreach ($blocks as $block) { $formattedBlock =
$block->
getBlock();
$formattedBlock['template'
] =
$block->
getTemplate();
$formattedBlock['styles'
] =
$block->
getStyles();