Skip to content

Commit

Permalink
Remove BlockContextManager
Browse files Browse the repository at this point in the history
  • Loading branch information
VincentLanglet committed Aug 8, 2022
1 parent a0275d3 commit d792fb8
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 128 deletions.
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.

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

This file was deleted.

3 changes: 0 additions & 3 deletions src/Resources/config/block.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@
<argument type="service" id="sonata.block.renderer"/>
<argument type="service" id="sonata.block.context_manager"/>
</service>
<service id="sonata.page.block.context_manager" class="Sonata\PageBundle\Block\BlockContextManager">
<argument type="service" id="sonata.block.context_manager.default"/>
</service>
<service id="sonata.page.block.breadcrumb" class="%sonata.page.block.breadcrumb.class%">
<tag name="sonata.block"/>
<tag name="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 @@ -196,27 +195,14 @@ public function renderContainer($name, $page = null, array $options = [])
*/
public function renderBlock(PageBlockInterface $block, array $options = [])
{
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.

0 comments on commit d792fb8

Please sign in to comment.