vendor/sonata-project/cache-bundle/src/Cache/TwigTemplateRecorderInjector.php line 38

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of the Sonata Project package.
  4.  *
  5.  * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
  6.  *
  7.  * For the full copyright and license information, please view the LICENSE
  8.  * file that was distributed with this source code.
  9.  */
  10. namespace Sonata\CacheBundle\Cache;
  11. use Sonata\Cache\Invalidation\Recorder;
  12. use Twig\Environment;
  13. use Twig\Extension\AbstractExtension;
  14. use Twig\Extension\InitRuntimeInterface;
  15. /**
  16.  * @internal
  17.  *
  18.  * NEXT_MAJOR: remove
  19.  */
  20. final class TwigTemplateRecorderInjector extends AbstractExtension implements InitRuntimeInterface
  21. {
  22.     /**
  23.      * @var Recorder
  24.      */
  25.     private $recorder;
  26.     public function __construct(Recorder $recorder)
  27.     {
  28.         $this->recorder $recorder;
  29.     }
  30.     public function initRuntime(Environment $environment)
  31.     {
  32.         $baseTemplateClass $environment->getBaseTemplateClass();
  33.         if (empty($baseTemplateClass)) {
  34.             return;
  35.         }
  36.         if (method_exists($baseTemplateClass'attachRecorder')) {
  37.             call_user_func([$baseTemplateClass'attachRecorder'], $this->recorder);
  38.         }
  39.     }
  40. }