mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-13 10:56:38 +00:00
removed InitRuntimeInterface and RuntimeExtensionInterface
This commit is contained in:
+1
-2
@@ -374,8 +374,7 @@ class Environment
|
||||
}
|
||||
}
|
||||
|
||||
// to be removed in 3.0
|
||||
$this->extensionSet->initRuntime($this);
|
||||
$this->extensionSet->initRuntime();
|
||||
|
||||
return $this->loadedTemplates[$cls] = new $cls($this);
|
||||
}
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Twig.
|
||||
*
|
||||
* (c) Fabien Potencier
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Twig\Extension;
|
||||
|
||||
use Twig\Environment;
|
||||
|
||||
/**
|
||||
* Enables usage of the deprecated Twig\Extension\AbstractExtension::initRuntime() method.
|
||||
*
|
||||
* Explicitly implement this interface if you really need to implement the
|
||||
* deprecated initRuntime() method in your extensions.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* @deprecated since Twig 2.7, to be removed in 3.0
|
||||
*/
|
||||
interface InitRuntimeInterface
|
||||
{
|
||||
/**
|
||||
* Initializes the runtime environment.
|
||||
*
|
||||
* This is where you can load some file that contains filter functions for instance.
|
||||
*/
|
||||
public function initRuntime(Environment $environment);
|
||||
}
|
||||
+1
-17
@@ -14,7 +14,6 @@ namespace Twig;
|
||||
use Twig\Error\RuntimeError;
|
||||
use Twig\Extension\ExtensionInterface;
|
||||
use Twig\Extension\GlobalsInterface;
|
||||
use Twig\Extension\InitRuntimeInterface;
|
||||
use Twig\Extension\StagingExtension;
|
||||
use Twig\NodeVisitor\NodeVisitorInterface;
|
||||
use Twig\TokenParser\TokenParserInterface;
|
||||
@@ -47,24 +46,9 @@ final class ExtensionSet
|
||||
$this->staging = new StagingExtension();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the runtime environment.
|
||||
*
|
||||
* @deprecated since Twig 2.7
|
||||
*/
|
||||
public function initRuntime(Environment $env)
|
||||
public function initRuntime()
|
||||
{
|
||||
if ($this->runtimeInitialized) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->runtimeInitialized = true;
|
||||
|
||||
foreach ($this->extensions as $extension) {
|
||||
if ($extension instanceof InitRuntimeInterface) {
|
||||
$extension->initRuntime($env);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function hasExtension(string $class): bool
|
||||
|
||||
@@ -15,7 +15,6 @@ use Twig\Environment;
|
||||
use Twig\Extension\AbstractExtension;
|
||||
use Twig\Extension\ExtensionInterface;
|
||||
use Twig\Extension\GlobalsInterface;
|
||||
use Twig\Extension\InitRuntimeInterface;
|
||||
use Twig\Loader\ArrayLoader;
|
||||
use Twig\Loader\LoaderInterface;
|
||||
use Twig\Node\Node;
|
||||
@@ -305,22 +304,6 @@ class Twig_Tests_EnvironmentTest extends \PHPUnit\Framework\TestCase
|
||||
$this->assertTrue($twig->isTemplateFresh('page', time()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
public function testInitRuntimeWithAnExtensionUsingInitRuntimeNoDeprecation()
|
||||
{
|
||||
$loader = $this->getMockBuilder(LoaderInterface::class)->getMock();
|
||||
$twig = new Environment($loader);
|
||||
$loader->expects($this->once())->method('getSourceContext')->will($this->returnValue(new Source('', '')));
|
||||
$twig->addExtension(new Twig_Tests_EnvironmentTest_ExtensionWithoutDeprecationInitRuntime());
|
||||
$twig->load('');
|
||||
|
||||
// add a dummy assertion here to satisfy PHPUnit, the only thing we want to test is that the code above
|
||||
// can be executed without throwing any deprecations
|
||||
$this->addToAssertionCount(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \LogicException
|
||||
* @expectedExceptionMessage Unable to register extension "Twig_Tests_EnvironmentTest_Extension" as it is already registered.
|
||||
@@ -479,20 +462,6 @@ class Twig_Tests_EnvironmentTest_NodeVisitor implements NodeVisitorInterface
|
||||
}
|
||||
}
|
||||
|
||||
class Twig_Tests_EnvironmentTest_ExtensionWithDeprecationInitRuntime extends AbstractExtension
|
||||
{
|
||||
public function initRuntime(Environment $env)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
class Twig_Tests_EnvironmentTest_ExtensionWithoutDeprecationInitRuntime extends AbstractExtension implements InitRuntimeInterface
|
||||
{
|
||||
public function initRuntime(Environment $env)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
class Twig_Tests_EnvironmentTest_ExtensionWithoutRuntime extends AbstractExtension
|
||||
{
|
||||
public function getFunctions()
|
||||
|
||||
Reference in New Issue
Block a user