Skip to content

Commit

Permalink
fix SonataBlockBundle deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
dmaicher authored and jordisala1991 committed Apr 27, 2022
1 parent 1f0b1ee commit b1a4a4b
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"knplabs/knp-menu-bundle": "^3.0",
"psr/container": "^1.0 || ^2.0",
"psr/log": "^1.1 || ^2.0 || ^3.0",
"sonata-project/block-bundle": "^4.7",
"sonata-project/block-bundle": "^4.11",
"sonata-project/doctrine-extensions": "^1.8",
"sonata-project/exporter": "^2.11",
"sonata-project/form-extensions": "^1.7.1",
Expand Down
2 changes: 1 addition & 1 deletion src/Block/AdminListBlockService.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function execute(BlockContextInterface $blockContext, ?Response $response
}
}

return $this->renderPrivateResponse($this->templateRegistry->getTemplate('list_block'), [
return $this->renderResponse($this->templateRegistry->getTemplate('list_block'), [
'block' => $blockContext->getBlock(),
'settings' => $settings,
'groups' => $visibleGroups,
Expand Down
2 changes: 1 addition & 1 deletion src/Block/AdminPreviewBlockService.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function execute(BlockContextInterface $blockContext, ?Response $response

$datagrid = $admin->getDatagrid();

return $this->renderPrivateResponse($template, [
return $this->renderResponse($template, [
'block' => $blockContext->getBlock(),
'settings' => $blockContext->getSettings(),
'admin' => $admin,
Expand Down
2 changes: 1 addition & 1 deletion src/Block/AdminSearchBlockService.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public function execute(BlockContextInterface $blockContext, ?Response $response
static fn (FilterInterface $filter): bool => $filter instanceof SearchableFilterInterface && $filter->isSearchEnabled()
);

return $this->renderPrivateResponse($this->templateRegistry->getTemplate('search_result_block'), [
return $this->renderResponse($this->templateRegistry->getTemplate('search_result_block'), [
'block' => $blockContext->getBlock(),
'settings' => $blockContext->getSettings(),
'pager' => $pager,
Expand Down
2 changes: 1 addition & 1 deletion src/Block/AdminStatsBlockService.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function execute(BlockContextInterface $blockContext, ?Response $response

$datagrid->buildPager();

return $this->renderPrivateResponse($template, [
return $this->renderResponse($template, [
'block' => $blockContext->getBlock(),
'settings' => $blockContext->getSettings(),
'admin' => $admin,
Expand Down
5 changes: 5 additions & 0 deletions tests/App/AppKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,11 @@ protected function configureContainer(ContainerBuilder $containerBuilder, Loader
]);

$loader->load(sprintf('%s/config/services.yml', $this->getProjectDir()));

// TODO: Remove when support for SonataBlockBundle 4 is dropped.
$containerBuilder->loadFromExtension('sonata_block', [
'http_cache' => false,
]);
}

private function getBaseDir(): string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,8 @@ private function setUpContainer(): void
$this->container->setAlias('translator', 'translator.default');

$blockExtension = new SonataBlockExtension();
$blockExtension->load([], $this->container);
// TODO: remove "http_cache" parameter when support for SonataBlockBundle 4 is dropped.
$blockExtension->load(['sonata_block' => ['http_cache' => false]], $this->container);
}

private function allowToResolveChildren(): void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,8 @@ private function getContainer(): ContainerBuilder
->setClass(FileLocatorInterface::class);

$blockExtension = new SonataBlockExtension();
$blockExtension->load([], $container);
// TODO: remove "http_cache" parameter when support for SonataBlockBundle 4 is dropped.
$blockExtension->load(['sonata_block' => ['http_cache' => false]], $container);

return $container;
}
Expand Down

0 comments on commit b1a4a4b

Please sign in to comment.