diff --git a/src/Symfony/Bundle/FrameworkBundle/Bundle/Bundle.php b/src/Symfony/Bundle/FrameworkBundle/Bundle/Bundle.php new file mode 100644 index 0000000000000..acf2565ff77d2 --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Bundle/Bundle.php @@ -0,0 +1,33 @@ +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) + )); + } + } + + +} \ No newline at end of file diff --git a/src/Symfony/Bundle/FrameworkBundle/Templating/Loader/TemplateLocator.php b/src/Symfony/Bundle/FrameworkBundle/Templating/Loader/TemplateLocator.php index 286b7c62e4d2a..7a679b06ffb74 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Templating/Loader/TemplateLocator.php +++ b/src/Symfony/Bundle/FrameworkBundle/Templating/Loader/TemplateLocator.php @@ -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); + if (!$template instanceof TemplateReferenceInterface) { throw new \InvalidArgumentException('The template must be an instance of TemplateReferenceInterface.'); } diff --git a/src/Symfony/Bundle/FrameworkBundle/Templating/TemplateNameParser.php b/src/Symfony/Bundle/FrameworkBundle/Templating/TemplateNameParser.php index 5730807facd4b..0cdc26817d688 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Templating/TemplateNameParser.php +++ b/src/Symfony/Bundle/FrameworkBundle/Templating/TemplateNameParser.php @@ -20,6 +20,7 @@ * "bundle:section:template.format.engine" to TemplateReferenceInterface * instances. * + * @deprecated since version 2.8, to be removed in 3.0 * @author Fabien Potencier */ class TemplateNameParser extends BaseTemplateNameParser @@ -48,6 +49,8 @@ public function parse($name) return $this->cache[$name]; } + trigger_error('The "bundle:section:template.format.engine" syntax is deprecated since version 2.8 and will be removed in 3.0.', E_USER_DEPRECATED); + // normalize name $name = str_replace(':/', ':', preg_replace('#/{2,}#', '/', strtr($name, '\\', '/'))); diff --git a/src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php b/src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php index 70ed9eed9c112..dcc3854a4d209 100644 --- a/src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php +++ b/src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php @@ -64,11 +64,16 @@ public function load(array $configs, ContainerBuilder $container) if (!$namespace) { $twigFilesystemLoaderDefinition->addMethodCall('addPath', array($path)); } else { + // register the "override" path + if (is_dir($dir = $container->getParameter('kernel.root_dir').'/Resources/'.$namespace.'/views')) { + $twigFilesystemLoaderDefinition->addMethodCall('addPath', array($dir, $namespace)); + } + $twigFilesystemLoaderDefinition->addMethodCall('addPath', array($path, $namespace)); } } - // register bundles as Twig namespaces + // register bundles as Twig namespaces (deprecated) foreach ($container->getParameter('kernel.bundles') as $bundle => $class) { if (is_dir($dir = $container->getParameter('kernel.root_dir').'/Resources/'.$bundle.'/views')) { $this->addTwigPath($twigFilesystemLoaderDefinition, $dir, $bundle); @@ -120,6 +125,9 @@ public function load(array $configs, ContainerBuilder $container) )); } + /** + * @deprecated The automatic @AcmeDemo (for AcmeDemoBundle) Twig path was deprecated in 2.8 and will be removed in 3.0 + */ private function addTwigPath($twigFilesystemLoaderDefinition, $dir, $bundle) { $name = $bundle; diff --git a/src/Symfony/Bundle/TwigBundle/Loader/FilesystemLoader.php b/src/Symfony/Bundle/TwigBundle/Loader/FilesystemLoader.php index 3c7f925d034d3..6337337756d19 100644 --- a/src/Symfony/Bundle/TwigBundle/Loader/FilesystemLoader.php +++ b/src/Symfony/Bundle/TwigBundle/Loader/FilesystemLoader.php @@ -78,7 +78,7 @@ protected function findTemplate($template) } catch (\Twig_Error_Loader $e) { $previous = $e; - // for BC + // deprecated - supports the bundle:directory:filename.format.engine format try { $template = $this->parser->parse($template); $file = $this->locator->locate($template); pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy