-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Deprecate some interface in Twig Bridge #16333
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <fabien@symfony.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Bridge\Twig\Extension; | ||
|
||
use Symfony\Component\DependencyInjection\ContainerInterface; | ||
|
||
/** | ||
* Loads Twig extension runtimes. | ||
* | ||
* @author Fabien Potencier <fabien@symfony.com> | ||
*/ | ||
class ContainerAwareRuntimeLoader implements \Twig_RuntimeLoaderInterface | ||
{ | ||
private $container; | ||
|
||
public function __construct(ContainerInterface $container) | ||
{ | ||
$this->container = $container; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function load($name) | ||
{ | ||
$id = 'twig.extension.runtime.'.$name; | ||
|
||
if ($this->container->has($id)) { | ||
return $this->container->get($id); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,8 @@ | |
|
||
/** | ||
* @author Bernhard Schussek <bschussek@gmail.com> | ||
* | ||
* @internal | ||
*/ | ||
class TwigRendererEngine extends AbstractRendererEngine implements TwigRendererEngineInterface | ||
{ | ||
|
@@ -29,12 +31,20 @@ class TwigRendererEngine extends AbstractRendererEngine implements TwigRendererE | |
*/ | ||
private $template; | ||
|
||
public function __construct(array $defaultThemes = array(), \Twig_Environment $environment) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is a BC break as the 2 arguments are mandatory There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't you think that this class is internal? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. people using it have to instantiate it explicitly. This signature change would break Silex for instance |
||
{ | ||
parent::__construct($defaultThemes); | ||
|
||
$this->environment = $environment; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
* | ||
* @deprecated Deprecated in 2.8, to be removed in 3.0. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. deprecation warnings should be added too |
||
*/ | ||
public function setEnvironment(\Twig_Environment $environment) | ||
{ | ||
$this->environment = $environment; | ||
} | ||
|
||
/** | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please don't force this convention: it forbids third-party bundles to use this behavior while following best practices for shared bundles. The id of the runtime should be provided as an optional attribute in the
twig.extension
tag IMO, to build a mapping between extension names and runtimesThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, this is just a quick POC to prove that it works.