-
-
Notifications
You must be signed in to change notification settings - Fork 142
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Deprecate caching related functionality (#1011)
* Deprecate caching related functionality * fix cs
- Loading branch information
Showing
20 changed files
with
419 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
src/DependencyInjection/Compiler/BlockHelperCompilerPass.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of the Sonata Project package. | ||
* | ||
* (c) Thomas Rabaix <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Sonata\BlockBundle\DependencyInjection\Compiler; | ||
|
||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; | ||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
use Symfony\Component\DependencyInjection\ContainerInterface; | ||
use Symfony\Component\DependencyInjection\Parameter; | ||
use Symfony\Component\DependencyInjection\Reference; | ||
|
||
/** | ||
* @internal | ||
* | ||
* NEXT_MAJOR: remove this class | ||
*/ | ||
final class BlockHelperCompilerPass implements CompilerPassInterface | ||
{ | ||
public function process(ContainerBuilder $container): void | ||
{ | ||
/** @var array{by_class: array<class-string, string>, by_type: array<string, string>} $cacheBlocks */ | ||
$cacheBlocks = $container->getParameter('sonata_block.cache_blocks'); | ||
|
||
$hasCacheBlocks = false; | ||
foreach ($cacheBlocks as $blocks) { | ||
foreach ($blocks as $cacheType) { | ||
$hasCacheBlocks = $hasCacheBlocks || 'sonata.cache.noop' !== $cacheType; | ||
} | ||
} | ||
|
||
if (!$hasCacheBlocks) { | ||
return; | ||
} | ||
|
||
@trigger_error( | ||
'Defining cache blocks other than \'sonata.cache.noop\' is deprecated since sonata-project/block-bundle 4.x and will not be supported anymore in 5.0.', | ||
\E_USER_DEPRECATED | ||
); | ||
|
||
$blockHelperDefinition = $container->getDefinition('sonata.block.templating.helper'); | ||
$blockHelperDefinition->setArguments([ | ||
new Reference('sonata.block.manager'), | ||
new Parameter('sonata_block.cache_blocks'), | ||
new Reference('sonata.block.renderer'), | ||
new Reference('sonata.block.context_manager'), | ||
new Reference('event_dispatcher'), | ||
new Reference('sonata.cache.manager', ContainerInterface::NULL_ON_INVALID_REFERENCE), | ||
new Reference('sonata.block.cache.handler', ContainerInterface::NULL_ON_INVALID_REFERENCE), | ||
new Reference('debug.stopwatch', ContainerInterface::NULL_ON_INVALID_REFERENCE), | ||
]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.