Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Block context manager #1524

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions UPGRADE-4.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,14 @@ All the deprecated code introduced on 3.x is removed on 4.0.
Please read [3.x](https://github.com/sonata-project/SonataPageBundle/tree/3.x) upgrade guides for more information.

See also the [diff code](https://github.com/sonata-project/SonataPageBundle/compare/3.x...4.0.0).

## BlockContextManager

The class `Sonata\PageBundle\Block\BlockContextManager` was removed.

Please be aware the config
```
sonata_block:
context_manager: sonata.page.block.context_manager
```
won't work anymore then. You should rely on the default value instead.
11 changes: 1 addition & 10 deletions docs/reference/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -138,16 +138,7 @@ SonataAdminBundle Configuration
SonataBlockBundle Configuration
-------------------------------

.. code-block:: yaml

# config/packages/sonata_block.yaml

sonata_block:
context_manager: sonata.page.block.context_manager

.. note::

Please you need to use the context ``sonata_page_bundle`` in the SonataBlockBundle to add block into a Page.
You need to use the context ``sonata_page_bundle`` in the SonataBlockBundle to add block into a Page.
jordisala1991 marked this conversation as resolved.
Show resolved Hide resolved

Security Configuration
----------------------
Expand Down
50 changes: 0 additions & 50 deletions src/Block/BlockContextManager.php

This file was deleted.

6 changes: 0 additions & 6 deletions src/Resources/config/block.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
*/

use Sonata\BlockBundle\Block\BlockServiceManagerInterface;
use Sonata\PageBundle\Block\BlockContextManager;
use Sonata\PageBundle\Block\BreadcrumbBlockService;
use Sonata\PageBundle\Block\ChildrenPagesBlockService;
use Sonata\PageBundle\Block\ContainerBlockService;
Expand Down Expand Up @@ -48,11 +47,6 @@
new ReferenceConfigurator('sonata.block.context_manager'),
])

->set('sonata.page.block.context_manager', BlockContextManager::class)
->args([
new ReferenceConfigurator('sonata.block.context_manager.default'),
])

->set('sonata.page.block.breadcrumb', BreadcrumbBlockService::class)
->tag('sonata.block')
->tag('sonata.breadcrumb')
Expand Down
24 changes: 5 additions & 19 deletions src/Twig/Extension/PageExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
use Sonata\PageBundle\Exception\PageNotFoundException;
use Sonata\PageBundle\Model\PageBlockInterface;
use Sonata\PageBundle\Model\PageInterface;
use Sonata\PageBundle\Model\SnapshotPageProxy;
use Sonata\PageBundle\Site\SiteSelectorInterface;
use Symfony\Bridge\Twig\Extension\HttpKernelExtension;
use Symfony\Component\HttpFoundation\RequestStack;
Expand Down Expand Up @@ -184,27 +183,14 @@ public function renderContainer(string $name, $page = null, array $options = [])
*/
public function renderBlock(PageBlockInterface $block, array $options = []): string
{
if (false === $block->getEnabled() && !$this->cmsManagerSelector->isEditor() && $this->hideDisabledBlocks) {
if (
false === $block->getEnabled()
&& !$this->cmsManagerSelector->isEditor()
&& $this->hideDisabledBlocks
) {
return '';
}

$page = $block->getPage();

// defined extra default key for the cache
$pageCacheKeys = null !== $page ? [
'manager' => $page instanceof SnapshotPageProxy ? 'snapshot' : 'page',
'page_id' => $page->getId(),
] : [];

// build the parameters array
$options = array_merge([
'use_cache' => $options['use_cache'] ?? true,
'extra_cache_keys' => [],
], $pageCacheKeys, $options);

// make sure the parameters array contains all valid keys
$options['extra_cache_keys'] = array_merge($options['extra_cache_keys'], $pageCacheKeys);

return $this->blockHelper->render($block, $options);
}

Expand Down
1 change: 0 additions & 1 deletion tests/App/config/sonata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ sonata_block:
blocks:
sonata.admin.block.admin_list:
contexts: [admin]
context_manager: sonata.page.block.context_manager
default_contexts: [sonata_page_bundle]

sonata_page:
Expand Down
45 changes: 0 additions & 45 deletions tests/Block/BlockContextManagerTest.php

This file was deleted.