Improving deprecation message of the Twig templates directory src/Resources/views
This commit is contained in:
parent
07a1095af9
commit
89a00b315d
@ -379,7 +379,7 @@ EOF
|
|||||||
$path = ltrim($relativePath.$name, \DIRECTORY_SEPARATOR);
|
$path = ltrim($relativePath.$name, \DIRECTORY_SEPARATOR);
|
||||||
$carry[$name] = $path;
|
$carry[$name] = $path;
|
||||||
|
|
||||||
@trigger_error(sprintf('Templates directory "%s" is deprecated since Symfony 4.2, use "%s" instead.', $absolutePath, $this->twigDefaultPath.'/bundles/'.$name), E_USER_DEPRECATED);
|
@trigger_error(sprintf('Loading Twig templates from the "%s" directory is deprecated since Symfony 4.2, use "%s" instead.', $absolutePath, $this->twigDefaultPath.'/bundles/'.$name), E_USER_DEPRECATED);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $carry;
|
return $carry;
|
||||||
|
@ -65,7 +65,7 @@ class DebugCommandTest extends TestCase
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @group legacy
|
* @group legacy
|
||||||
* @expectedDeprecation Templates directory "%sResources/BarBundle/views" is deprecated since Symfony 4.2, use "%stemplates/bundles/BarBundle" instead.
|
* @expectedDeprecation Loading Twig templates from the "%sResources/BarBundle/views" directory is deprecated since Symfony 4.2, use "%stemplates/bundles/BarBundle" instead.
|
||||||
*/
|
*/
|
||||||
public function testDeprecationForWrongBundleOverridingInLegacyPath()
|
public function testDeprecationForWrongBundleOverridingInLegacyPath()
|
||||||
{
|
{
|
||||||
|
@ -145,7 +145,7 @@ EOF
|
|||||||
$viewsPaths = [];
|
$viewsPaths = [];
|
||||||
if (is_dir($dir = $rootDir.'/Resources/views')) {
|
if (is_dir($dir = $rootDir.'/Resources/views')) {
|
||||||
if ($dir !== $this->defaultViewsPath) {
|
if ($dir !== $this->defaultViewsPath) {
|
||||||
$notice = sprintf('Storing templates in the "%s" directory is deprecated since Symfony 4.2, ', $dir);
|
$notice = sprintf('Loading Twig templates from the "%s" directory is deprecated since Symfony 4.2, ', $dir);
|
||||||
@trigger_error($notice.($this->defaultViewsPath ? sprintf('use the "%s" directory instead.', $this->defaultViewsPath) : 'configure and use "twig.default_path" instead.'), E_USER_DEPRECATED);
|
@trigger_error($notice.($this->defaultViewsPath ? sprintf('use the "%s" directory instead.', $this->defaultViewsPath) : 'configure and use "twig.default_path" instead.'), E_USER_DEPRECATED);
|
||||||
}
|
}
|
||||||
$viewsPaths[] = $dir;
|
$viewsPaths[] = $dir;
|
||||||
@ -173,7 +173,7 @@ EOF
|
|||||||
}
|
}
|
||||||
if (is_dir($dir = sprintf('%s/Resources/%s/views', $rootDir, $bundle->getName()))) {
|
if (is_dir($dir = sprintf('%s/Resources/%s/views', $rootDir, $bundle->getName()))) {
|
||||||
$viewsPaths[] = $dir;
|
$viewsPaths[] = $dir;
|
||||||
$notice = sprintf('Storing templates for "%s" in the "%s" directory is deprecated since Symfony 4.2, ', $bundle->getName(), $dir);
|
$notice = sprintf('Loading Twig templates for "%s" from the "%s" directory is deprecated since Symfony 4.2, ', $bundle->getName(), $dir);
|
||||||
@trigger_error($notice.($this->defaultViewsPath ? sprintf('use the "%s" directory instead.', $this->defaultViewsPath) : 'configure and use "twig.default_path" instead.'), E_USER_DEPRECATED);
|
@trigger_error($notice.($this->defaultViewsPath ? sprintf('use the "%s" directory instead.', $this->defaultViewsPath) : 'configure and use "twig.default_path" instead.'), E_USER_DEPRECATED);
|
||||||
}
|
}
|
||||||
} catch (\InvalidArgumentException $e) {
|
} catch (\InvalidArgumentException $e) {
|
||||||
@ -191,7 +191,7 @@ EOF
|
|||||||
$viewsPaths = [$path.'/templates'];
|
$viewsPaths = [$path.'/templates'];
|
||||||
if (is_dir($dir = $path.'/Resources/views')) {
|
if (is_dir($dir = $path.'/Resources/views')) {
|
||||||
if ($dir !== $this->defaultViewsPath) {
|
if ($dir !== $this->defaultViewsPath) {
|
||||||
@trigger_error(sprintf('Storing templates in the "%s" directory is deprecated since Symfony 4.2, use the "%s" directory instead.', $dir, $path.'/templates'), E_USER_DEPRECATED);
|
@trigger_error(sprintf('Loading Twig templates from the "%s" directory is deprecated since Symfony 4.2, use the "%s" directory instead.', $dir, $path.'/templates'), E_USER_DEPRECATED);
|
||||||
}
|
}
|
||||||
$viewsPaths[] = $dir;
|
$viewsPaths[] = $dir;
|
||||||
}
|
}
|
||||||
@ -211,7 +211,7 @@ EOF
|
|||||||
$viewsPaths[] = $bundle->getPath().'/Resources/views';
|
$viewsPaths[] = $bundle->getPath().'/Resources/views';
|
||||||
if (is_dir($deprecatedPath = sprintf('%s/Resources/%s/views', $rootDir, $bundle->getName()))) {
|
if (is_dir($deprecatedPath = sprintf('%s/Resources/%s/views', $rootDir, $bundle->getName()))) {
|
||||||
$viewsPaths[] = $deprecatedPath;
|
$viewsPaths[] = $deprecatedPath;
|
||||||
$notice = sprintf('Storing templates for "%s" in the "%s" directory is deprecated since Symfony 4.2, ', $bundle->getName(), $deprecatedPath);
|
$notice = sprintf('Loading Twig templates for "%s" from the "%s" directory is deprecated since Symfony 4.2, ', $bundle->getName(), $deprecatedPath);
|
||||||
@trigger_error($notice.($this->defaultViewsPath ? sprintf('use the "%s" directory instead.', $this->defaultViewsPath) : 'configure and use "twig.default_path" instead.'), E_USER_DEPRECATED);
|
@trigger_error($notice.($this->defaultViewsPath ? sprintf('use the "%s" directory instead.', $this->defaultViewsPath) : 'configure and use "twig.default_path" instead.'), E_USER_DEPRECATED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -117,7 +117,7 @@ class TwigExtension extends Extension
|
|||||||
|
|
||||||
if (file_exists($dir = $container->getParameter('kernel.root_dir').'/Resources/views')) {
|
if (file_exists($dir = $container->getParameter('kernel.root_dir').'/Resources/views')) {
|
||||||
if ($dir !== $defaultTwigPath) {
|
if ($dir !== $defaultTwigPath) {
|
||||||
@trigger_error(sprintf('Templates directory "%s" is deprecated since Symfony 4.2, use "%s" instead.', $dir, $defaultTwigPath), E_USER_DEPRECATED);
|
@trigger_error(sprintf('Loading Twig templates from the "%s" directory is deprecated since Symfony 4.2, use "%s" instead.', $dir, $defaultTwigPath), E_USER_DEPRECATED);
|
||||||
}
|
}
|
||||||
|
|
||||||
$twigFilesystemLoaderDefinition->addMethodCall('addPath', [$dir]);
|
$twigFilesystemLoaderDefinition->addMethodCall('addPath', [$dir]);
|
||||||
@ -172,7 +172,7 @@ class TwigExtension extends Extension
|
|||||||
$defaultOverrideBundlePath = $container->getParameterBag()->resolveValue($config['default_path']).'/bundles/'.$name;
|
$defaultOverrideBundlePath = $container->getParameterBag()->resolveValue($config['default_path']).'/bundles/'.$name;
|
||||||
|
|
||||||
if (file_exists($dir = $container->getParameter('kernel.root_dir').'/Resources/'.$name.'/views')) {
|
if (file_exists($dir = $container->getParameter('kernel.root_dir').'/Resources/'.$name.'/views')) {
|
||||||
@trigger_error(sprintf('Templates directory "%s" is deprecated since Symfony 4.2, use "%s" instead.', $dir, $defaultOverrideBundlePath), E_USER_DEPRECATED);
|
@trigger_error(sprintf('Loading Twig templates for "%s" from the "%s" directory is deprecated since Symfony 4.2, use "%s" instead.', $name, $dir, $defaultOverrideBundlePath), E_USER_DEPRECATED);
|
||||||
|
|
||||||
$bundleHierarchy[$name][] = $dir;
|
$bundleHierarchy[$name][] = $dir;
|
||||||
}
|
}
|
||||||
|
@ -203,8 +203,8 @@ class TwigExtensionTest extends TestCase
|
|||||||
/**
|
/**
|
||||||
* @group legacy
|
* @group legacy
|
||||||
* @dataProvider getFormats
|
* @dataProvider getFormats
|
||||||
* @expectedDeprecation Templates directory "%s/Resources/TwigBundle/views" is deprecated since Symfony 4.2, use "%s/templates/bundles/TwigBundle" instead.
|
* @expectedDeprecation Loading Twig templates for "TwigBundle" from the "%s/Resources/TwigBundle/views" directory is deprecated since Symfony 4.2, use "%s/templates/bundles/TwigBundle" instead.
|
||||||
* @expectedDeprecation Templates directory "%s/Resources/views" is deprecated since Symfony 4.2, use "%s/templates" instead.
|
* @expectedDeprecation Loading Twig templates from the "%s/Resources/views" directory is deprecated since Symfony 4.2, use "%s/templates" instead.
|
||||||
*/
|
*/
|
||||||
public function testLegacyTwigLoaderPaths($format)
|
public function testLegacyTwigLoaderPaths($format)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user