-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
[WIP] Explicitly Declare Twig "Paths", deprecate old syntaxes #13928
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
31c4eef
03322b2
793fc32
0325692
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,33 @@ | ||
<?php | ||
|
||
namespace Symfony\Bundle\FrameworkBundle\Bundle; | ||
|
||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
use Symfony\Component\HttpKernel\Bundle\Bundle as BaseBundle; | ||
|
||
class Bundle extends BaseBundle | ||
{ | ||
private $twigPaths = array(); | ||
|
||
protected function addTwigPath($templateDirectory, $namespace) | ||
{ | ||
$this->twigPaths[$namespace] = $templateDirectory; | ||
} | ||
|
||
public function build(ContainerBuilder $container) | ||
{ | ||
foreach ($this->twigPaths as $namespace => $directory) { | ||
if (!is_dir($directory)) { | ||
throw new \InvalidArgumentException(sprintf( | ||
'Directory "%s" does not exist, so it cannot be added as a Twig path', $directory | ||
)); | ||
} | ||
|
||
$container->prependExtensionConfig('twig', array( | ||
'paths' => array($directory => $namespace) | ||
)); | ||
} | ||
} | ||
|
||
|
||
} | ||
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. missing final new line feed :) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,9 +62,13 @@ protected function getCacheKey($template) | |
* | ||
* @throws \InvalidArgumentException When the template is not an instance of TemplateReferenceInterface | ||
* @throws \InvalidArgumentException When the template file can not be found | ||
* | ||
* @deprecated since version 2.8, to be removed in 3.0. | ||
*/ | ||
public function locate($template, $currentPath = null, $first = true) | ||
{ | ||
trigger_error('The '.__METHOD__.' is deprecated since version 2.8 and will be removed in 3.0.', E_USER_DEPRECATED); | ||
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. will 2.8 ever exist? 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. not settled yet. This is in discussion in the core team |
||
|
||
if (!$template instanceof TemplateReferenceInterface) { | ||
throw new \InvalidArgumentException('The template must be an instance of TemplateReferenceInterface.'); | ||
} | ||
|
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.
symfony doesn't wrap lines like that, this should all be on one line