From fd4269025314dc19793cf187a47846725586b142 Mon Sep 17 00:00:00 2001 From: Michael Babker Date: Sat, 20 May 2017 10:54:14 -0500 Subject: [PATCH] Remove ContainerAwareRuntimeLoader --- src/Symfony/Bundle/TwigBundle/CHANGELOG.md | 5 ++ .../ContainerAwareRuntimeLoader.php | 52 ------------------- .../Tests/ContainerAwareRuntimeLoaderTest.php | 41 --------------- 3 files changed, 5 insertions(+), 93 deletions(-) delete mode 100644 src/Symfony/Bundle/TwigBundle/ContainerAwareRuntimeLoader.php delete mode 100644 src/Symfony/Bundle/TwigBundle/Tests/ContainerAwareRuntimeLoaderTest.php diff --git a/src/Symfony/Bundle/TwigBundle/CHANGELOG.md b/src/Symfony/Bundle/TwigBundle/CHANGELOG.md index 9f666dbc29dd7..e22b52714caf8 100644 --- a/src/Symfony/Bundle/TwigBundle/CHANGELOG.md +++ b/src/Symfony/Bundle/TwigBundle/CHANGELOG.md @@ -1,6 +1,11 @@ CHANGELOG ========= +4.0.0 +----- + + * Removed `ContainerAwareRuntimeLoader` + 3.3.0 ----- diff --git a/src/Symfony/Bundle/TwigBundle/ContainerAwareRuntimeLoader.php b/src/Symfony/Bundle/TwigBundle/ContainerAwareRuntimeLoader.php deleted file mode 100644 index e2988f3aae5e0..0000000000000 --- a/src/Symfony/Bundle/TwigBundle/ContainerAwareRuntimeLoader.php +++ /dev/null @@ -1,52 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bundle\TwigBundle; - -@trigger_error(sprintf('The %s class is deprecated since version 3.3 and will be removed in 4.0. Use the Twig_ContainerRuntimeLoader class instead.', ContainerAwareRuntimeLoader::class), E_USER_DEPRECATED); - -use Psr\Log\LoggerInterface; -use Symfony\Component\DependencyInjection\ContainerInterface; - -/** - * Loads Twig extension runtimes via the service container. - * - * @author Fabien Potencier - * - * @deprecated since version 3.3, will be removed in 4.0. Use \Twig_ContainerRuntimeLoader instead. - */ -class ContainerAwareRuntimeLoader implements \Twig_RuntimeLoaderInterface -{ - private $container; - private $mapping; - private $logger; - - public function __construct(ContainerInterface $container, array $mapping, LoggerInterface $logger = null) - { - $this->container = $container; - $this->mapping = $mapping; - $this->logger = $logger; - } - - /** - * {@inheritdoc} - */ - public function load($class) - { - if (isset($this->mapping[$class])) { - return $this->container->get($this->mapping[$class]); - } - - if (null !== $this->logger) { - $this->logger->warning(sprintf('Class "%s" is not configured as a Twig runtime. Add the "twig.runtime" tag to the related service in the container.', $class)); - } - } -} diff --git a/src/Symfony/Bundle/TwigBundle/Tests/ContainerAwareRuntimeLoaderTest.php b/src/Symfony/Bundle/TwigBundle/Tests/ContainerAwareRuntimeLoaderTest.php deleted file mode 100644 index 93202ca987b16..0000000000000 --- a/src/Symfony/Bundle/TwigBundle/Tests/ContainerAwareRuntimeLoaderTest.php +++ /dev/null @@ -1,41 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bundle\TwigBundle\Tests; - -use Psr\Log\LoggerInterface; -use Symfony\Component\DependencyInjection\ContainerInterface; -use Symfony\Bundle\TwigBundle\ContainerAwareRuntimeLoader; - -/** - * @group legacy - */ -class ContainerAwareRuntimeLoaderTest extends TestCase -{ - public function testLoad() - { - $container = $this->getMockBuilder(ContainerInterface::class)->getMock(); - $container->expects($this->once())->method('get')->with('foo'); - - $loader = new ContainerAwareRuntimeLoader($container, array( - 'FooClass' => 'foo', - )); - $loader->load('FooClass'); - } - - public function testLoadWithoutAMatch() - { - $logger = $this->getMockBuilder(LoggerInterface::class)->getMock(); - $logger->expects($this->once())->method('warning')->with('Class "BarClass" is not configured as a Twig runtime. Add the "twig.runtime" tag to the related service in the container.'); - $loader = new ContainerAwareRuntimeLoader($this->getMockBuilder(ContainerInterface::class)->getMock(), array(), $logger); - $this->assertNull($loader->load('BarClass')); - } -}