diff --git a/src/Symfony/Bridge/Twig/Extension/AssetExtension.php b/src/Symfony/Bridge/Twig/Extension/AssetExtension.php
index 3e9e9f6a78e27..f599a9eb5c9b6 100644
--- a/src/Symfony/Bridge/Twig/Extension/AssetExtension.php
+++ b/src/Symfony/Bridge/Twig/Extension/AssetExtension.php
@@ -12,7 +12,6 @@
namespace Symfony\Bridge\Twig\Extension;
use Symfony\Component\Asset\Packages;
-use Symfony\Component\Asset\VersionStrategy\StaticVersionStrategy;
/**
* Twig extension for the Symfony Asset component.
@@ -22,16 +21,10 @@
class AssetExtension extends \Twig_Extension
{
private $packages;
- private $foundationExtension;
- /**
- * Passing an HttpFoundationExtension instance as a second argument must not be relied on
- * as it's only there to maintain BC with older Symfony version. It will be removed in 3.0.
- */
- public function __construct(Packages $packages, HttpFoundationExtension $foundationExtension = null)
+ public function __construct(Packages $packages)
{
$this->packages = $packages;
- $this->foundationExtension = $foundationExtension;
}
/**
@@ -42,7 +35,6 @@ public function getFunctions()
return array(
new \Twig_SimpleFunction('asset', array($this, 'getAssetUrl')),
new \Twig_SimpleFunction('asset_version', array($this, 'getAssetVersion')),
- new \Twig_SimpleFunction('assets_version', array($this, 'getAssetsVersion')),
);
}
@@ -57,20 +49,8 @@ public function getFunctions()
*
* @return string The public path of the asset
*/
- public function getAssetUrl($path, $packageName = null, $absolute = false, $version = null)
+ public function getAssetUrl($path, $packageName = null)
{
- // BC layer to be removed in 3.0
- if (2 < $count = func_num_args()) {
- trigger_error('Generating absolute URLs with the Twig asset() function was deprecated in 2.7 and will be removed in 3.0. Please use absolute_url() instead.', E_USER_DEPRECATED);
- if (4 === $count) {
- trigger_error('Forcing a version with the Twig asset() function was deprecated in 2.7 and will be removed in 3.0.', E_USER_DEPRECATED);
- }
-
- $args = func_get_args();
-
- return $this->getLegacyAssetUrl($path, $packageName, $args[2], isset($args[3]) ? $args[3] : null);
- }
-
return $this->packages->getUrl($path, $packageName);
}
@@ -87,51 +67,6 @@ public function getAssetVersion($path, $packageName = null)
return $this->packages->getVersion($path, $packageName);
}
- public function getAssetsVersion($packageName = null)
- {
- trigger_error('The Twig assets_version() function was deprecated in 2.7 and will be removed in 3.0. Please use asset_version() instead.', E_USER_DEPRECATED);
-
- return $this->packages->getVersion('/', $packageName);
- }
-
- private function getLegacyAssetUrl($path, $packageName = null, $absolute = false, $version = null)
- {
- if ($version) {
- $package = $this->packages->getPackage($packageName);
-
- $v = new \ReflectionProperty($package, 'versionStrategy');
- $v->setAccessible(true);
-
- $currentVersionStrategy = $v->getValue($package);
-
- $f = new \ReflectionProperty($currentVersionStrategy, 'format');
- $f->setAccessible(true);
- $format = $f->getValue($currentVersionStrategy);
-
- $v->setValue($package, new StaticVersionStrategy($version, $format));
- }
-
- try {
- $url = $this->packages->getUrl($path, $packageName);
- } catch (\Exception $e) {
- if ($version) {
- $v->setValue($package, $currentVersionStrategy);
- }
-
- throw $e;
- }
-
- if ($version) {
- $v->setValue($package, $currentVersionStrategy);
- }
-
- if ($absolute) {
- return $this->foundationExtension->generateAbsoluteUrl($url);
- }
-
- return $url;
- }
-
/**
* Returns the name of the extension.
*
diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/AssetExtensionTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/AssetExtensionTest.php
deleted file mode 100644
index 4c67f4fd1901d..0000000000000
--- a/src/Symfony/Bridge/Twig/Tests/Extension/AssetExtensionTest.php
+++ /dev/null
@@ -1,40 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Symfony\Bridge\Twig\Tests\Extension;
-
-use Symfony\Bridge\Twig\Extension\AssetExtension;
-use Symfony\Component\Asset\Package;
-use Symfony\Component\Asset\Packages;
-use Symfony\Component\Asset\VersionStrategy\StaticVersionStrategy;
-
-class AssetExtensionTest extends \PHPUnit_Framework_TestCase
-{
- public function testLegacyGetAssetUrl()
- {
- $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
-
- $foundationExtension = $this->getMockBuilder('Symfony\Bridge\Twig\Extension\HttpFoundationExtension')->disableOriginalConstructor()->getMock();
- $foundationExtension
- ->expects($this->any())
- ->method('generateAbsoluteUrl')
- ->will($this->returnCallback(function ($arg) { return 'http://localhost/'.$arg; }))
- ;
-
- $package = new Package(new StaticVersionStrategy('22', '%s?version=%s'));
- $packages = new Packages($package);
- $extension = new AssetExtension($packages, $foundationExtension);
-
- $this->assertEquals('me.png?version=42', $extension->getAssetUrl('me.png', null, false, '42'));
- $this->assertEquals('http://localhost/me.png?version=22', $extension->getAssetUrl('me.png', null, true));
- $this->assertEquals('http://localhost/me.png?version=42', $extension->getAssetUrl('me.png', null, true, '42'));
- }
-}
diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/TemplatingAssetHelperPass.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/TemplatingAssetHelperPass.php
deleted file mode 100644
index 5e59391e9c884..0000000000000
--- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/TemplatingAssetHelperPass.php
+++ /dev/null
@@ -1,71 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler;
-
-use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
-use Symfony\Component\DependencyInjection\ContainerBuilder;
-use Symfony\Component\DependencyInjection\Definition;
-use Symfony\Component\DependencyInjection\Reference;
-
-trigger_error('The '.__NAMESPACE__.'\TemplatingAssetHelperPass class is deprecated since version 2.7 and will be removed in 3.0.', E_USER_DEPRECATED);
-
-/**
- * @deprecated since 2.7, will be removed in 3.0
- */
-class TemplatingAssetHelperPass implements CompilerPassInterface
-{
- public function process(ContainerBuilder $container)
- {
- if (!$container->hasDefinition('templating.helper.assets')) {
- return;
- }
-
- $assetsHelperDefinition = $container->getDefinition('templating.helper.assets');
- $args = $assetsHelperDefinition->getArguments();
-
- if ('request' === $this->getPackageScope($container, $args[0])) {
- $assetsHelperDefinition->setScope('request');
-
- return;
- }
-
- if (!array_key_exists(1, $args)) {
- return;
- }
-
- if (!is_array($args[1])) {
- return;
- }
-
- foreach ($args[1] as $arg) {
- if ('request' === $this->getPackageScope($container, $arg)) {
- $assetsHelperDefinition->setScope('request');
-
- break;
- }
- }
- }
-
- private function getPackageScope(ContainerBuilder $container, $package)
- {
- if ($package instanceof Reference) {
- return $container->findDefinition((string) $package)->getScope();
- }
-
- if ($package instanceof Definition) {
- return $package->getScope();
- }
-
- // Someone did some voodoo with a compiler pass. So we ignore this
- // 'package'. Can we be sure, it's a package anyway?
- }
-}
diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php
index 95aa34c50ef74..b85d5eef939e5 100644
--- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php
+++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php
@@ -53,44 +53,6 @@ public function getConfigTreeBuilder()
return $v;
})
->end()
- ->validate()
- ->ifTrue(function ($v) { return isset($v['templating']); })
- ->then(function ($v) {
- if ($v['templating']['assets_version']
- || count($v['templating']['assets_base_urls']['http'])
- || count($v['templating']['assets_base_urls']['ssl'])
- || count($v['templating']['packages'])
- ) {
- trigger_error('The assets settings under framework.templating are deprecated since version 2.7 and will be removed in 3.0. Use the framework.assets configuration key instead', E_USER_DEPRECATED);
-
- // convert the old configuration to the new one
- if (isset($v['assets'])) {
- throw new LogicException('You cannot use assets settings under "templating.templating" and "assets" configurations in the same project.');
- }
-
- $v['assets'] = array(
- 'version' => $v['templating']['assets_version'],
- 'version_format' => $v['templating']['assets_version_format'],
- 'base_path' => '',
- 'base_urls' => array_values(array_unique(array_merge($v['templating']['assets_base_urls']['http'], $v['templating']['assets_base_urls']['ssl']))),
- 'packages' => array(),
- );
-
- foreach ($v['templating']['packages'] as $name => $config) {
- $v['assets']['packages'][$name] = array(
- 'version' => (string) $config['version'],
- 'version_format' => $config['version_format'],
- 'base_path' => '',
- 'base_urls' => array_values(array_unique(array_merge($config['base_urls']['http'], $config['base_urls']['ssl']))),
- );
- }
- }
-
- unset($v['templating']['assets_version'], $v['templating']['assets_version_format'], $v['templating']['assets_base_urls'], $v['templating']['packages']);
-
- return $v;
- })
- ->end()
->children()
->scalarNode('secret')->end()
->scalarNode('http_method_override')
@@ -360,35 +322,14 @@ private function addRequestSection(ArrayNodeDefinition $rootNode)
private function addTemplatingSection(ArrayNodeDefinition $rootNode)
{
- $organizeUrls = function ($urls) {
- $urls += array(
- 'http' => array(),
- 'ssl' => array(),
- );
-
- foreach ($urls as $i => $url) {
- if (is_integer($i)) {
- if (0 === strpos($url, 'https://') || 0 === strpos($url, '//')) {
- $urls['http'][] = $urls['ssl'][] = $url;
- } else {
- $urls['http'][] = $url;
- }
- unset($urls[$i]);
- }
- }
-
- return $urls;
- };
-
$rootNode
->children()
->arrayNode('templating')
->info('templating configuration')
->canBeUnset()
->children()
- ->scalarNode('assets_version')->defaultNull()->info('Deprecated since 2.7, will be removed in 3.0. Use the new assets entry instead.')->end()
- ->scalarNode('assets_version_format')->defaultValue('%%s?%%s')->info('Deprecated since 2.7, will be removed in 3.0. Use the new assets entry instead.')->end()
->scalarNode('hinclude_default_template')->defaultNull()->end()
+ ->scalarNode('cache')->end()
->arrayNode('form')
->addDefaultsIfNotSet()
->fixXmlConfig('resource')
@@ -406,31 +347,6 @@ private function addTemplatingSection(ArrayNodeDefinition $rootNode)
->end()
->end()
->end()
- ->fixXmlConfig('assets_base_url')
- ->children()
- ->arrayNode('assets_base_urls')
- ->info('Deprecated since 2.7, will be removed in 3.0. Use the new assets entry instead.')
- ->performNoDeepMerging()
- ->addDefaultsIfNotSet()
- ->beforeNormalization()
- ->ifTrue(function ($v) { return !is_array($v); })
- ->then(function ($v) { return array($v); })
- ->end()
- ->beforeNormalization()
- ->always()
- ->then($organizeUrls)
- ->end()
- ->children()
- ->arrayNode('http')
- ->prototype('scalar')->end()
- ->end()
- ->arrayNode('ssl')
- ->prototype('scalar')->end()
- ->end()
- ->end()
- ->end()
- ->scalarNode('cache')->end()
- ->end()
->fixXmlConfig('engine')
->children()
->arrayNode('engines')
@@ -454,40 +370,6 @@ private function addTemplatingSection(ArrayNodeDefinition $rootNode)
->prototype('scalar')->end()
->end()
->end()
- ->fixXmlConfig('package')
- ->children()
- ->arrayNode('packages')
- ->info('Deprecated since 2.7, will be removed in 3.0. Use the new assets entry instead.')
- ->useAttributeAsKey('name')
- ->prototype('array')
- ->fixXmlConfig('base_url')
- ->children()
- ->scalarNode('version')->defaultNull()->end()
- ->scalarNode('version_format')->defaultValue('%%s?%%s')->end()
- ->arrayNode('base_urls')
- ->performNoDeepMerging()
- ->addDefaultsIfNotSet()
- ->beforeNormalization()
- ->ifTrue(function ($v) { return !is_array($v); })
- ->then(function ($v) { return array($v); })
- ->end()
- ->beforeNormalization()
- ->always()
- ->then($organizeUrls)
- ->end()
- ->children()
- ->arrayNode('http')
- ->prototype('scalar')->end()
- ->end()
- ->arrayNode('ssl')
- ->prototype('scalar')->end()
- ->end()
- ->end()
- ->end()
- ->end()
- ->end()
- ->end()
- ->end()
->end()
->end()
;
diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd b/src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd
index 652d168a77266..61222abec9566 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd
+++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd
@@ -152,13 +152,9 @@
-
-
-
-
@@ -169,16 +165,6 @@
-
-
-
-
-
-
-
-
-
-
diff --git a/src/Symfony/Bundle/FrameworkBundle/Templating/Asset/PackageFactory.php b/src/Symfony/Bundle/FrameworkBundle/Templating/Asset/PackageFactory.php
deleted file mode 100644
index ef76796a26f82..0000000000000
--- a/src/Symfony/Bundle/FrameworkBundle/Templating/Asset/PackageFactory.php
+++ /dev/null
@@ -1,49 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Symfony\Bundle\FrameworkBundle\Templating\Asset;
-
-trigger_error('The Symfony\Bundle\FrameworkBundle\Templating\Asset\PackageFactory is deprecated since version 2.7 and will be removed in 3.0. Use the Asset component instead.', E_USER_DEPRECATED);
-
-use Symfony\Component\DependencyInjection\ContainerInterface;
-use Symfony\Component\HttpFoundation\Request;
-use Symfony\Component\Templating\Asset\PackageInterface;
-
-/**
- * Creates packages based on whether the current request is secure.
- *
- * @author Kris Wallsmith
- *
- * @deprecated since 2.7, will be removed in 3.0. Use the Asset component instead.
- */
-class PackageFactory
-{
- private $container;
-
- public function __construct(ContainerInterface $container)
- {
- $this->container = $container;
- }
-
- /**
- * Returns either the HTTP or SSL version of an asset package.
- *
- * @param Request $request The current request
- * @param string $httpId The id for the package to use when the current request is HTTP
- * @param string $sslId The id for the package to use when the current request is SSL
- *
- * @return PackageInterface The package
- */
- public function getPackage(Request $request, $httpId, $sslId)
- {
- return $this->container->get($request->isSecure() ? $sslId : $httpId);
- }
-}
diff --git a/src/Symfony/Bundle/FrameworkBundle/Templating/Asset/PathPackage.php b/src/Symfony/Bundle/FrameworkBundle/Templating/Asset/PathPackage.php
deleted file mode 100644
index e75e25106ba65..0000000000000
--- a/src/Symfony/Bundle/FrameworkBundle/Templating/Asset/PathPackage.php
+++ /dev/null
@@ -1,39 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Symfony\Bundle\FrameworkBundle\Templating\Asset;
-
-use Symfony\Component\HttpFoundation\Request;
-use Symfony\Component\Templating\Asset\PathPackage as BasePathPackage;
-
-trigger_error('The Symfony\Bundle\FrameworkBundle\Templating\Asset\PathPackage is deprecated since version 2.7 and will be removed in 3.0. Use the Asset component instead.', E_USER_DEPRECATED);
-
-/**
- * The path packages adds a version and a base path to asset URLs.
- *
- * @author Kris Wallsmith
- *
- * @deprecated since 2.7, will be removed in 3.0. Use the Asset component instead.
- */
-class PathPackage extends BasePathPackage
-{
- /**
- * Constructor.
- *
- * @param Request $request The current request
- * @param string $version The version
- * @param string $format The version format
- */
- public function __construct(Request $request, $version = null, $format = null)
- {
- parent::__construct($request->getBasePath(), $version, $format);
- }
-}
diff --git a/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/AssetsHelper.php b/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/AssetsHelper.php
deleted file mode 100644
index dcbb6bfe5669b..0000000000000
--- a/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/AssetsHelper.php
+++ /dev/null
@@ -1,126 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Symfony\Bundle\FrameworkBundle\Templating\Helper;
-
-use Symfony\Component\Asset\Packages;
-use Symfony\Component\Asset\VersionStrategy\StaticVersionStrategy;
-use Symfony\Component\Templating\Helper\Helper;
-
-/**
- * AssetsHelper helps manage asset URLs.
- *
- * @author Fabien Potencier
- */
-class AssetsHelper extends Helper
-{
- private $packages;
-
- public function __construct(Packages $packages)
- {
- $this->packages = $packages;
- }
-
- /**
- * Returns the public url/path of an asset.
- *
- * If the package used to generate the path is an instance of
- * UrlPackage, you will always get a URL and not a path.
- *
- * @param string $path A public path
- * @param string $packageName The name of the asset package to use
- *
- * @return string The public path of the asset
- */
- public function getUrl($path, $packageName = null, $version = null)
- {
- // BC layer to be removed in 3.0
- if (3 === $count = func_num_args()) {
- trigger_error('Forcing a version for an asset was deprecated in 2.7 and will be removed in 3.0.', E_USER_DEPRECATED);
-
- $args = func_get_args();
-
- return $this->getLegacyAssetUrl($path, $packageName, $args[2]);
- }
-
- return $this->packages->getUrl($path, $packageName);
- }
-
- /**
- * Returns the version of an asset.
- *
- * @param string $path A public path
- * @param string $packageName The name of the asset package to use
- *
- * @return string The asset version
- */
- public function getVersion($path = null, $packageName = null)
- {
- // no arguments means old getVersion() for default package
- if (null === $path) {
- trigger_error('The getVersion() method requires a path as a first argument since 2.7 and will be enforced as of 3.0.', E_USER_DEPRECATED);
-
- return $this->packages->getVersion('/', $packageName);
- }
-
- // path and packageName can only be for the new version
- if (null !== $packageName) {
- return $this->packages->getVersion($path, $packageName);
- }
-
- // packageName is null and path not, so path is a path or a packageName
- try {
- $package = $this->packages->getPackage($path);
- } catch (\InvalidArgumentException $e) {
- // path is not a package, so it should be a path
- return $this->packages->getVersion($path);
- }
-
- // path is a packageName, old version
- trigger_error('The getVersion() method requires a path as a first argument since 2.7 and will be enforced as of 3.0.', E_USER_DEPRECATED);
-
- return $this->packages->getVersion('/', $path);
- }
-
- private function getLegacyAssetUrl($path, $packageName = null, $version = null)
- {
- if ($version) {
- $package = $this->packages->getPackage($packageName);
-
- $v = new \ReflectionProperty($package, 'versionStrategy');
- $v->setAccessible(true);
-
- $currentVersionStrategy = $v->getValue($package);
-
- $f = new \ReflectionProperty($currentVersionStrategy, 'format');
- $f->setAccessible(true);
- $format = $f->getValue($currentVersionStrategy);
-
- $v->setValue($package, new StaticVersionStrategy($version, $format));
- }
-
- $url = $this->packages->getUrl($path, $packageName);
-
- if ($version) {
- $v->setValue($package, $currentVersionStrategy);
- }
-
- return $url;
- }
-
- /**
- * {@inheritdoc}
- */
- public function getName()
- {
- return 'assets';
- }
-}
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/LegacyTemplatingAssetHelperPassTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/LegacyTemplatingAssetHelperPassTest.php
deleted file mode 100644
index 10a6e08568b04..0000000000000
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/LegacyTemplatingAssetHelperPassTest.php
+++ /dev/null
@@ -1,121 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler;
-
-use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\TemplatingAssetHelperPass;
-use Symfony\Component\DependencyInjection\ContainerBuilder;
-use Symfony\Component\DependencyInjection\Definition;
-use Symfony\Component\DependencyInjection\Reference;
-
-class LegacyTemplatingAssetHelperPassTest extends \PHPUnit_Framework_TestCase
-{
- public function getScopesTests()
- {
- return array(
- array('container'),
- array('request'),
- );
- }
-
- /** @dataProvider getScopesTests */
- public function testFindLowestScopeInDefaultPackageWithReference($scope)
- {
- $container = new ContainerBuilder();
-
- $defaultPackage = new Definition('stdClass');
- $defaultPackage->setScope($scope);
- $container->setDefinition('default_package', $defaultPackage);
-
- $definition = new Definition('stdClass', array(new Reference('default_package')));
- $container->setDefinition('templating.helper.assets', $definition);
-
- $profilerPass = new TemplatingAssetHelperPass();
- $profilerPass->process($container);
-
- $this->assertSame($scope, $definition->getScope());
- }
-
- /** @dataProvider getScopesTests */
- public function testFindLowestScopeInDefaultPackageWithDefinition($scope)
- {
- $container = new ContainerBuilder();
-
- $defaultPackage = new Definition('stdClass');
- $defaultPackage->setScope($scope);
-
- $definition = new Definition('stdClass', array($defaultPackage));
- $container->setDefinition('templating.helper.assets', $definition);
-
- $profilerPass = new TemplatingAssetHelperPass();
- $profilerPass->process($container);
-
- $this->assertSame($scope, $definition->getScope());
- }
-
- /** @dataProvider getScopesTests */
- public function testFindLowestScopeInNamedPackageWithReference($scope)
- {
- $container = new ContainerBuilder();
-
- $defaultPackage = new Definition('stdClass');
- $container->setDefinition('default_package', $defaultPackage);
-
- $aPackage = new Definition('stdClass');
- $container->setDefinition('a_package', $aPackage);
-
- $bPackage = new Definition('stdClass');
- $bPackage->setScope($scope);
- $container->setDefinition('b_package', $bPackage);
-
- $cPackage = new Definition('stdClass');
- $container->setDefinition('c_package', $cPackage);
-
- $definition = new Definition('stdClass', array(new Reference('default_package'), array(
- new Reference('a_package'),
- new Reference('b_package'),
- new Reference('c_package'),
- )));
- $container->setDefinition('templating.helper.assets', $definition);
-
- $profilerPass = new TemplatingAssetHelperPass();
- $profilerPass->process($container);
-
- $this->assertSame($scope, $definition->getScope());
- }
-
- /** @dataProvider getScopesTests */
- public function testFindLowestScopeInNamedPackageWithDefinition($scope)
- {
- $container = new ContainerBuilder();
-
- $defaultPackage = new Definition('stdClass');
-
- $aPackage = new Definition('stdClass');
-
- $bPackage = new Definition('stdClass');
- $bPackage->setScope($scope);
-
- $cPackage = new Definition('stdClass');
-
- $definition = new Definition('stdClass', array($defaultPackage, array(
- $aPackage,
- $bPackage,
- $cPackage,
- )));
- $container->setDefinition('templating.helper.assets', $definition);
-
- $profilerPass = new TemplatingAssetHelperPass();
- $profilerPass->process($container);
-
- $this->assertSame($scope, $definition->getScope());
- }
-}
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/legacy_templating_assets.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/legacy_templating_assets.php
deleted file mode 100644
index 32bd56b3587d5..0000000000000
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/legacy_templating_assets.php
+++ /dev/null
@@ -1,23 +0,0 @@
-loadFromExtension('framework', array(
- 'templating' => array(
- 'engines' => array('php'),
- 'assets_version' => 'SomeVersionScheme',
- 'assets_base_urls' => 'http://cdn.example.com',
- 'assets_version_format' => '%%s?version=%%s',
- 'packages' => array(
- 'images' => array(
- 'version' => '1.0.0',
- 'base_urls' => array('http://images1.example.com', 'http://images2.example.com'),
- ),
- 'foo' => array(
- 'version' => '1.0.0',
- 'version_format' => '%%s-%%s',
- ),
- 'bar' => array(
- 'base_urls' => array('https://bar2.example.com'),
- ),
- ),
- ),
-));
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/legacy_templating_url_package.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/legacy_templating_url_package.php
deleted file mode 100644
index afbd7bc460b9f..0000000000000
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/legacy_templating_url_package.php
+++ /dev/null
@@ -1,14 +0,0 @@
-loadFromExtension('framework', array(
- 'secret' => 's3cr3t',
- 'templating' => array(
- 'assets_base_urls' => 'https://cdn.example.com',
- 'engines' => array('php', 'twig'),
- 'packages' => array(
- 'images' => array(
- 'base_urls' => 'https://images.example.com',
- ),
- ),
- ),
-));
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/legacy_templating_assets.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/legacy_templating_assets.yml
deleted file mode 100644
index e8cc6ce41d31c..0000000000000
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/legacy_templating_assets.yml
+++ /dev/null
@@ -1,15 +0,0 @@
-framework:
- templating:
- engines: [php]
- assets_version: SomeVersionScheme
- assets_version_format: %%s?version=%%s
- assets_base_urls: http://cdn.example.com
- packages:
- images:
- version: 1.0.0
- base_urls: ["http://images1.example.com", "http://images2.example.com"]
- foo:
- version: 1.0.0
- version_format: %%s-%%s
- bar:
- base_urls: "https://bar2.example.com"
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/legacy_templating_url_package.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/legacy_templating_url_package.yml
deleted file mode 100644
index bfec7a19cc49c..0000000000000
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/legacy_templating_url_package.yml
+++ /dev/null
@@ -1,8 +0,0 @@
-framework:
- secret: s3cr3t
- templating:
- assets_base_urls: https://cdn.example.com
- engines: [php, twig]
- packages:
- images:
- base_urls: https://images.example.com
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php
index 344065d623c8e..88e059fc6c9f9 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php
@@ -203,16 +203,30 @@ public function testTemplating()
$this->assertEquals('global_hinclude_template', $container->getParameter('fragment.renderer.hinclude.global_template'), '->registerTemplatingConfiguration() registers the global hinclude.js template');
}
- public function testLegacyTemplatingAssets()
+ public function testAssets()
{
- $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
+ $container = $this->createContainerFromFile('assets');
+ $packages = $container->getDefinition('assets.packages');
- $this->checkAssetsPackages($this->createContainerFromFile('legacy_templating_assets'), true);
- }
+ // default package
+ $defaultPackage = $container->getDefinition($packages->getArgument(0));
+ $this->assertUrlPackage($container, $defaultPackage, array('http://cdn.example.com'), 'SomeVersionScheme', '%%s?version=%%s');
- public function testAssets()
- {
- $this->checkAssetsPackages($this->createContainerFromFile('assets'));
+ // packages
+ $packages = $packages->getArgument(1);
+ $this->assertCount(4, $packages);
+
+ $package = $container->getDefinition($packages['images_path']);
+ $this->assertPathPackage($container, $package, '/foo', 'SomeVersionScheme', '%%s?version=%%s');
+
+ $package = $container->getDefinition($packages['images']);
+ $this->assertUrlPackage($container, $package, array('http://images1.example.com', 'http://images2.example.com'), '1.0.0', '%%s?version=%%s');
+
+ $package = $container->getDefinition($packages['foo']);
+ $this->assertPathPackage($container, $package, '', '1.0.0', '%%s-%%s');
+
+ $package = $container->getDefinition($packages['bar']);
+ $this->assertUrlPackage($container, $package, array('https://bar2.example.com'), 'SomeVersionScheme', '%%s?version=%%s');
}
public function testTranslator()
@@ -535,33 +549,6 @@ protected function createContainerFromClosure($closure, $data = array())
return $container;
}
- private function checkAssetsPackages(ContainerBuilder $container, $legacy = false)
- {
- $packages = $container->getDefinition('assets.packages');
-
- // default package
- $defaultPackage = $container->getDefinition($packages->getArgument(0));
- $this->assertUrlPackage($container, $defaultPackage, array('http://cdn.example.com'), 'SomeVersionScheme', '%%s?version=%%s');
-
- // packages
- $packages = $packages->getArgument(1);
- $this->assertCount($legacy ? 3 : 4, $packages);
-
- if (!$legacy) {
- $package = $container->getDefinition($packages['images_path']);
- $this->assertPathPackage($container, $package, '/foo', 'SomeVersionScheme', '%%s?version=%%s');
- }
-
- $package = $container->getDefinition($packages['images']);
- $this->assertUrlPackage($container, $package, array('http://images1.example.com', 'http://images2.example.com'), '1.0.0', $legacy ? '%%s?%%s' : '%%s?version=%%s');
-
- $package = $container->getDefinition($packages['foo']);
- $this->assertPathPackage($container, $package, '', '1.0.0', '%%s-%%s');
-
- $package = $container->getDefinition($packages['bar']);
- $this->assertUrlPackage($container, $package, array('https://bar2.example.com'), $legacy ? '' : 'SomeVersionScheme', $legacy ? '%%s?%%s' : '%%s?version=%%s');
- }
-
private function assertPathPackage(ContainerBuilder $container, Definition $package, $basePath, $version, $format)
{
$this->assertEquals('assets.path_package', $package->getParent());
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/AssetsHelper.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/AssetsHelper.php
deleted file mode 100644
index 7ef641d756974..0000000000000
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/AssetsHelper.php
+++ /dev/null
@@ -1,46 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Symfony\Bundle\FrameworkBundle\Tests\Templating\Helper;
-
-use Symfony\Bundle\FrameworkBundle\Templating\Helper\AssetsHelper;
-use Symfony\Component\Asset\Package;
-use Symfony\Component\Asset\Packages;
-use Symfony\Component\Asset\VersionStrategy\StaticVersionStrategy;
-
-class AssetsHelperTest extends \PHPUnit_Framework_TestCase
-{
- public function testLegacyGetUrl()
- {
- $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
-
- $package = new Package(new StaticVersionStrategy('22', '%s?version=%s'));
- $packages = new Packages($package);
- $helper = new AssetsHelper($packages);
-
- $this->assertEquals('me.png?version=42', $helper->getUrl('me.png', null, '42'));
- }
-
- public function testLegacyGetVersion()
- {
- $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
-
- $package = new Package(new StaticVersionStrategy('22'));
- $imagePackage = new Package(new StaticVersionStrategy('42'));
- $packages = new Packages($package, array('images' => $imagePackage));
- $helper = new AssetsHelper($packages);
-
- $this->assertEquals('22', $helper->getVersion());
- $this->assertEquals('22', $helper->getVersion('/foo'));
- $this->assertEquals('42', $helper->getVersion('images'));
- $this->assertEquals('42', $helper->getVersion('/foo', 'images'));
- }
-}
diff --git a/src/Symfony/Bundle/TwigBundle/Command/DebugCommand.php b/src/Symfony/Bundle/TwigBundle/Command/DebugCommand.php
index 572e92a2e7074..99d67dd97454d 100644
--- a/src/Symfony/Bundle/TwigBundle/Command/DebugCommand.php
+++ b/src/Symfony/Bundle/TwigBundle/Command/DebugCommand.php
@@ -12,8 +12,6 @@
namespace Symfony\Bundle\TwigBundle\Command;
use Symfony\Bridge\Twig\Command\DebugCommand as BaseDebugCommand;
-use Symfony\Component\Console\Input\InputInterface;
-use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
@@ -44,23 +42,4 @@ protected function getTwigEnvironment()
{
return $this->container->get('twig');
}
-
- /**
- * {@inheritdoc}
- */
- protected function configure()
- {
- parent::configure();
-
- $this->setAliases(array('twig:debug'));
- }
-
- protected function execute(InputInterface $input, OutputInterface $output)
- {
- if (false !== strpos($input->getFirstArgument(), ':d')) {
- $output->writeln('The use of "twig:debug" command is deprecated since version 2.7 and will be removed in 3.0. Use the "debug:twig" instead.');
- }
-
- parent::execute($input, $output);
- }
}
diff --git a/src/Symfony/Bundle/TwigBundle/Debug/TimedTwigEngine.php b/src/Symfony/Bundle/TwigBundle/Debug/TimedTwigEngine.php
deleted file mode 100644
index 826af7925fabf..0000000000000
--- a/src/Symfony/Bundle/TwigBundle/Debug/TimedTwigEngine.php
+++ /dev/null
@@ -1,60 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Symfony\Bundle\TwigBundle\Debug;
-
-trigger_error('The '.__NAMESPACE__.'\TimedTwigEngine class is deprecated since version 2.7 and will be removed in 3.0. Use the Twig native profiler instead.', E_USER_DEPRECATED);
-
-use Symfony\Bundle\TwigBundle\TwigEngine;
-use Symfony\Component\Templating\TemplateNameParserInterface;
-use Symfony\Component\Stopwatch\Stopwatch;
-use Symfony\Component\Config\FileLocatorInterface;
-
-/**
- * Times the time spent to render a template.
- *
- * @author Fabien Potencier
- *
- * @deprecated since version 2.7, to be removed in 3.0. Use the Twig native profiler instead.
- */
-class TimedTwigEngine extends TwigEngine
-{
- protected $stopwatch;
-
- /**
- * Constructor.
- *
- * @param \Twig_Environment $environment A \Twig_Environment instance
- * @param TemplateNameParserInterface $parser A TemplateNameParserInterface instance
- * @param FileLocatorInterface $locator A FileLocatorInterface instance
- * @param Stopwatch $stopwatch A Stopwatch instance
- */
- public function __construct(\Twig_Environment $environment, TemplateNameParserInterface $parser, FileLocatorInterface $locator, Stopwatch $stopwatch)
- {
- parent::__construct($environment, $parser, $locator);
-
- $this->stopwatch = $stopwatch;
- }
-
- /**
- * {@inheritdoc}
- */
- public function render($name, array $parameters = array())
- {
- $e = $this->stopwatch->start(sprintf('template.twig (%s)', $name), 'template');
-
- $ret = parent::render($name, $parameters);
-
- $e->stop();
-
- return $ret;
- }
-}
diff --git a/src/Symfony/Bundle/TwigBundle/Extension/AssetsExtension.php b/src/Symfony/Bundle/TwigBundle/Extension/AssetsExtension.php
deleted file mode 100644
index 9d03aa7079010..0000000000000
--- a/src/Symfony/Bundle/TwigBundle/Extension/AssetsExtension.php
+++ /dev/null
@@ -1,129 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Symfony\Bundle\TwigBundle\Extension;
-
-use Symfony\Component\DependencyInjection\ContainerInterface;
-use Symfony\Component\Routing\RequestContext;
-
-trigger_error('The '.__NAMESPACE__.'\AssetsExtension class is deprecated since version 2.7 and will be removed in 3.0. Use the Symfony\Bridge\Twig\Extension\AssetExtension class instead.', E_USER_DEPRECATED);
-
-/**
- * Twig extension for Symfony assets helper.
- *
- * @author Fabien Potencier
- *
- * @deprecated since 2.7, to be removed in 3.0. Use Symfony\Component\Twig\Extension\AssetExtension instead.
- */
-class AssetsExtension extends \Twig_Extension
-{
- private $container;
- private $context;
-
- public function __construct(ContainerInterface $container, RequestContext $requestContext = null)
- {
- $this->container = $container;
- $this->context = $requestContext;
- }
-
- /**
- * Returns a list of functions to add to the existing list.
- *
- * @return array An array of functions
- */
- public function getFunctions()
- {
- return array(
- new \Twig_SimpleFunction('asset', array($this, 'getAssetUrl')),
- new \Twig_SimpleFunction('assets_version', array($this, 'getAssetsVersion')),
- );
- }
-
- /**
- * Returns the public path of an asset.
- *
- * Absolute paths (i.e. http://...) are returned unmodified.
- *
- * @param string $path A public path
- * @param string $packageName The name of the asset package to use
- * @param bool $absolute Whether to return an absolute URL or a relative one
- * @param string|bool|null $version A specific version
- *
- * @return string A public path which takes into account the base path and URL path
- */
- public function getAssetUrl($path, $packageName = null, $absolute = false, $version = null)
- {
- $url = $this->container->get('templating.helper.assets')->getUrl($path, $packageName, $version);
-
- if (!$absolute) {
- return $url;
- }
-
- return $this->ensureUrlIsAbsolute($url);
- }
-
- /**
- * Returns the version of the assets in a package.
- *
- * @param string $packageName
- *
- * @return int
- */
- public function getAssetsVersion($packageName = null)
- {
- return $this->container->get('templating.helper.assets')->getVersion($packageName);
- }
-
- /**
- * Returns the name of the extension.
- *
- * @return string The extension name
- */
- public function getName()
- {
- return 'assets';
- }
-
- /**
- * Ensures an URL is absolute, if possible.
- *
- * @param string $url The URL that has to be absolute
- *
- * @throws \RuntimeException
- *
- * @return string The absolute URL
- */
- private function ensureUrlIsAbsolute($url)
- {
- if (false !== strpos($url, '://') || 0 === strpos($url, '//')) {
- return $url;
- }
-
- if (!$this->context) {
- throw new \RuntimeException('To generate an absolute URL for an asset, the Symfony Routing component is required.');
- }
-
- if ('' === $host = $this->context->getHost()) {
- return $url;
- }
-
- $scheme = $this->context->getScheme();
- $port = '';
-
- if ('http' === $scheme && 80 != $this->context->getHttpPort()) {
- $port = ':'.$this->context->getHttpPort();
- } elseif ('https' === $scheme && 443 != $this->context->getHttpsPort()) {
- $port = ':'.$this->context->getHttpsPort();
- }
-
- return $scheme.'://'.$host.$port.$url;
- }
-}
diff --git a/src/Symfony/Bundle/TwigBundle/Resources/config/twig.xml b/src/Symfony/Bundle/TwigBundle/Resources/config/twig.xml
index 0286993728472..b828d6ff2872f 100644
--- a/src/Symfony/Bundle/TwigBundle/Resources/config/twig.xml
+++ b/src/Symfony/Bundle/TwigBundle/Resources/config/twig.xml
@@ -87,7 +87,6 @@
-
diff --git a/src/Symfony/Bundle/TwigBundle/Tests/Extension/LegacyAssetsExtensionTest.php b/src/Symfony/Bundle/TwigBundle/Tests/Extension/LegacyAssetsExtensionTest.php
deleted file mode 100644
index 425349942f436..0000000000000
--- a/src/Symfony/Bundle/TwigBundle/Tests/Extension/LegacyAssetsExtensionTest.php
+++ /dev/null
@@ -1,106 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Symfony\Bundle\TwigBundle\Tests\Extension;
-
-use Symfony\Bundle\TwigBundle\Extension\AssetsExtension;
-use Symfony\Bundle\TwigBundle\Tests\TestCase;
-use Symfony\Component\Routing\RequestContext;
-
-class LegacyAssetsExtensionTest extends TestCase
-{
- /**
- * @dataProvider provideGetGetAssetUrlArguments
- */
- public function testGetAssetUrl($path, $packageName, $absolute, $relativeUrl, $expectedUrl, $scheme, $host, $httpPort, $httpsPort)
- {
- $helper = $this->createHelperMock($path, $packageName, $relativeUrl);
- $container = $this->createContainerMock($helper);
-
- $context = $this->createRequestContextMock($scheme, $host, $httpPort, $httpsPort);
-
- $extension = new AssetsExtension($container, $context);
- $this->assertEquals($expectedUrl, $extension->getAssetUrl($path, $packageName, $absolute));
- }
-
- public function testGetAssetWithoutHost()
- {
- $path = '/path/to/asset';
- $packageName = null;
- $relativeUrl = '/bundle-name/path/to/asset';
-
- $helper = $this->createHelperMock($path, $packageName, $relativeUrl);
- $container = $this->createContainerMock($helper);
-
- $context = $this->createRequestContextMock('http', '', 80, 443);
-
- $extension = new AssetsExtension($container, $context);
- $this->assertEquals($relativeUrl, $extension->getAssetUrl($path, $packageName, true));
- }
-
- public function provideGetGetAssetUrlArguments()
- {
- return array(
- array('/path/to/asset', 'package-name', false, '/bundle-name/path/to/asset', '/bundle-name/path/to/asset', 'http', 'symfony.com', 80, null),
- array('/path/to/asset', 'package-name', false, 'http://subdomain.symfony.com/bundle-name/path/to/asset', 'http://subdomain.symfony.com/bundle-name/path/to/asset', 'http', 'symfony.com', 80, null),
- array('/path/to/asset', null, false, '/bundle-name/path/to/asset', '/bundle-name/path/to/asset', 'http', 'symfony.com', 80, null),
- array('/path/to/asset', 'package-name', true, '/bundle-name/path/to/asset', 'http://symfony.com/bundle-name/path/to/asset', 'http', 'symfony.com', 80, null),
- array('/path/to/asset', 'package-name', true, 'http://subdomain.symfony.com/bundle-name/path/to/asset', 'http://subdomain.symfony.com/bundle-name/path/to/asset', 'http', 'symfony.com', 80, null),
- array('/path/to/asset', null, true, '/bundle-name/path/to/asset', 'https://symfony.com:92/bundle-name/path/to/asset', 'https', 'symfony.com', null, 92),
- array('/path/to/asset', null, true, '/bundle-name/path/to/asset', 'http://symfony.com:660/bundle-name/path/to/asset', 'http', 'symfony.com', 660, null),
- );
- }
-
- private function createRequestContextMock($scheme, $host, $httpPort, $httpsPort)
- {
- $context = $this->getMockBuilder('Symfony\Component\Routing\RequestContext')
- ->disableOriginalConstructor()
- ->getMock();
- $context->expects($this->any())
- ->method('getScheme')
- ->will($this->returnValue($scheme));
- $context->expects($this->any())
- ->method('getHost')
- ->will($this->returnValue($host));
- $context->expects($this->any())
- ->method('getHttpPort')
- ->will($this->returnValue($httpPort));
- $context->expects($this->any())
- ->method('getHttpsPort')
- ->will($this->returnValue($httpsPort));
-
- return $context;
- }
-
- private function createContainerMock($helper)
- {
- $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
- $container->expects($this->any())
- ->method('get')
- ->with('templating.helper.assets')
- ->will($this->returnValue($helper));
-
- return $container;
- }
-
- private function createHelperMock($path, $packageName, $returnValue)
- {
- $helper = $this->getMockBuilder('Symfony\Component\Templating\Helper\CoreAssetsHelper')
- ->disableOriginalConstructor()
- ->getMock();
- $helper->expects($this->any())
- ->method('getUrl')
- ->with($path, $packageName)
- ->will($this->returnValue($returnValue));
-
- return $helper;
- }
-}
diff --git a/src/Symfony/Component/Templating/Asset/Package.php b/src/Symfony/Component/Templating/Asset/Package.php
deleted file mode 100644
index cfc33ccbcf92e..0000000000000
--- a/src/Symfony/Component/Templating/Asset/Package.php
+++ /dev/null
@@ -1,83 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Symfony\Component\Templating\Asset;
-
-trigger_error('The Symfony\Component\Templating\Asset\Package is deprecated since version 2.7 and will be removed in 3.0. Use the Asset component instead.', E_USER_DEPRECATED);
-
-/**
- * The basic package will add a version to asset URLs.
- *
- * @author Kris Wallsmith
- *
- * @deprecated since 2.7, will be removed in 3.0. Use the Asset component instead.
- */
-class Package implements PackageInterface
-{
- private $version;
- private $format;
-
- /**
- * Constructor.
- *
- * @param string $version The package version
- * @param string $format The format used to apply the version
- */
- public function __construct($version = null, $format = '')
- {
- $this->version = $version;
- $this->format = $format ?: '%s?%s';
- }
-
- /**
- * {@inheritdoc}
- */
- public function getVersion()
- {
- return $this->version;
- }
-
- /**
- * {@inheritdoc}
- */
- public function getUrl($path, $version = null)
- {
- if (false !== strpos($path, '://') || 0 === strpos($path, '//')) {
- return $path;
- }
-
- return $this->applyVersion($path, $version);
- }
-
- /**
- * Applies version to the supplied path.
- *
- * @param string $path A path
- * @param string|bool|null $version A specific version
- *
- * @return string The versionized path
- */
- protected function applyVersion($path, $version = null)
- {
- $version = null !== $version ? $version : $this->version;
- if (null === $version || false === $version) {
- return $path;
- }
-
- $versionized = sprintf($this->format, ltrim($path, '/'), $version);
-
- if ($path && '/' == $path[0]) {
- $versionized = '/'.$versionized;
- }
-
- return $versionized;
- }
-}
diff --git a/src/Symfony/Component/Templating/Asset/PackageInterface.php b/src/Symfony/Component/Templating/Asset/PackageInterface.php
deleted file mode 100644
index f19f6fc3c42f5..0000000000000
--- a/src/Symfony/Component/Templating/Asset/PackageInterface.php
+++ /dev/null
@@ -1,41 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Symfony\Component\Templating\Asset;
-
-trigger_error('The Symfony\Component\Templating\Asset\PackageInterface is deprecated since version 2.7 and will be removed in 3.0. Use the Asset component instead.', E_USER_DEPRECATED);
-
-/**
- * Asset package interface.
- *
- * @author Kris Wallsmith
- *
- * @deprecated since 2.7, will be removed in 3.0. Use the Asset component instead.
- */
-interface PackageInterface
-{
- /**
- * Returns the asset package version.
- *
- * @return string The version string
- */
- public function getVersion();
-
- /**
- * Returns an absolute or root-relative public path.
- *
- * @param string $path A path
- * @param string|bool|null $version A specific version for the path
- *
- * @return string The public path
- */
- public function getUrl($path, $version = null);
-}
diff --git a/src/Symfony/Component/Templating/Asset/PathPackage.php b/src/Symfony/Component/Templating/Asset/PathPackage.php
deleted file mode 100644
index 48f69523df095..0000000000000
--- a/src/Symfony/Component/Templating/Asset/PathPackage.php
+++ /dev/null
@@ -1,77 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Symfony\Component\Templating\Asset;
-
-trigger_error('The Symfony\Component\Templating\Asset\PathPackage is deprecated since version 2.7 and will be removed in 3.0. Use the Asset component instead.', E_USER_DEPRECATED);
-
-/**
- * The path packages adds a version and a base path to asset URLs.
- *
- * @author Kris Wallsmith
- *
- * @deprecated since 2.7, will be removed in 3.0. Use the Asset component instead.
- */
-class PathPackage extends Package
-{
- private $basePath;
-
- /**
- * Constructor.
- *
- * @param string $basePath The base path to be prepended to relative paths
- * @param string $version The package version
- * @param string $format The format used to apply the version
- */
- public function __construct($basePath = null, $version = null, $format = null)
- {
- parent::__construct($version, $format);
-
- if (!$basePath) {
- $this->basePath = '/';
- } else {
- if ('/' != $basePath[0]) {
- $basePath = '/'.$basePath;
- }
-
- $this->basePath = rtrim($basePath, '/').'/';
- }
- }
-
- /**
- * {@inheritdoc}
- */
- public function getUrl($path, $version = null)
- {
- if (false !== strpos($path, '://') || 0 === strpos($path, '//')) {
- return $path;
- }
-
- $url = $this->applyVersion($path, $version);
-
- // apply the base path
- if ('/' !== substr($url, 0, 1)) {
- $url = $this->basePath.$url;
- }
-
- return $url;
- }
-
- /**
- * Returns the base path.
- *
- * @return string The base path
- */
- public function getBasePath()
- {
- return $this->basePath;
- }
-}
diff --git a/src/Symfony/Component/Templating/Asset/UrlPackage.php b/src/Symfony/Component/Templating/Asset/UrlPackage.php
deleted file mode 100644
index 2ab1d0f9d53a6..0000000000000
--- a/src/Symfony/Component/Templating/Asset/UrlPackage.php
+++ /dev/null
@@ -1,86 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Symfony\Component\Templating\Asset;
-
-trigger_error('The Symfony\Component\Templating\Asset\UrlPackage is deprecated since version 2.7 and will be removed in 3.0. Use the Asset component instead.', E_USER_DEPRECATED);
-
-/**
- * The URL packages adds a version and a base URL to asset URLs.
- *
- * @author Kris Wallsmith
- *
- * @deprecated since 2.7, will be removed in 3.0. Use the Asset component instead.
- */
-class UrlPackage extends Package
-{
- private $baseUrls;
-
- /**
- * Constructor.
- *
- * @param string|array $baseUrls Base asset URLs
- * @param string $version The package version
- * @param string $format The format used to apply the version
- */
- public function __construct($baseUrls = array(), $version = null, $format = null)
- {
- parent::__construct($version, $format);
-
- if (!is_array($baseUrls)) {
- $baseUrls = (array) $baseUrls;
- }
-
- $this->baseUrls = array();
- foreach ($baseUrls as $baseUrl) {
- $this->baseUrls[] = rtrim($baseUrl, '/');
- }
- }
-
- /**
- * {@inheritdoc}
- */
- public function getUrl($path, $version = null)
- {
- if (false !== strpos($path, '://') || 0 === strpos($path, '//')) {
- return $path;
- }
-
- $url = $this->applyVersion($path, $version);
-
- if ($url && '/' != $url[0]) {
- $url = '/'.$url;
- }
-
- return $this->getBaseUrl($path).$url;
- }
-
- /**
- * Returns the base URL for a path.
- *
- * @param string $path
- *
- * @return string The base URL
- */
- public function getBaseUrl($path)
- {
- switch ($count = count($this->baseUrls)) {
- case 0:
- return '';
-
- case 1:
- return $this->baseUrls[0];
-
- default:
- return $this->baseUrls[fmod(hexdec(substr(hash('sha256', $path), 0, 10)), $count)];
- }
- }
-}
diff --git a/src/Symfony/Component/Templating/Helper/AssetsHelper.php b/src/Symfony/Component/Templating/Helper/AssetsHelper.php
deleted file mode 100644
index aceff61b61be9..0000000000000
--- a/src/Symfony/Component/Templating/Helper/AssetsHelper.php
+++ /dev/null
@@ -1,54 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Symfony\Component\Templating\Helper;
-
-trigger_error('The Symfony\Component\Templating\Helper\AssetsHelper is deprecated since version 2.7 and will be removed in 3.0. Use the Asset component instead.', E_USER_DEPRECATED);
-
-use Symfony\Component\Templating\Asset\PathPackage;
-use Symfony\Component\Templating\Asset\UrlPackage;
-
-/**
- * AssetsHelper helps manage asset URLs.
- *
- * Usage:
- *
- *
- *
- *
- *
- * @author Fabien Potencier
- * @author Kris Wallsmith
- *
- * @deprecated since 2.7, will be removed in 3.0. Use the Asset component instead.
- */
-class AssetsHelper extends CoreAssetsHelper
-{
- /**
- * Constructor.
- *
- * @param string $basePath The base path
- * @param string|array $baseUrls Base asset URLs
- * @param string $version The asset version
- * @param string $format The version format
- * @param array $namedPackages Additional packages
- */
- public function __construct($basePath = null, $baseUrls = array(), $version = null, $format = null, $namedPackages = array())
- {
- if ($baseUrls) {
- $defaultPackage = new UrlPackage($baseUrls, $version, $format);
- } else {
- $defaultPackage = new PathPackage($basePath, $version, $format);
- }
-
- parent::__construct($defaultPackage, $namedPackages);
- }
-}
diff --git a/src/Symfony/Component/Templating/Helper/CoreAssetsHelper.php b/src/Symfony/Component/Templating/Helper/CoreAssetsHelper.php
deleted file mode 100644
index 41076a1bfb5b8..0000000000000
--- a/src/Symfony/Component/Templating/Helper/CoreAssetsHelper.php
+++ /dev/null
@@ -1,132 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Symfony\Component\Templating\Helper;
-
-trigger_error('The Symfony\Component\Templating\Helper\CoreAssetsHelper is deprecated since version 2.7 and will be removed in 3.0. Use the Asset component instead.', E_USER_DEPRECATED);
-
-use Symfony\Component\Templating\Asset\PackageInterface;
-
-/**
- * CoreAssetsHelper helps manage asset URLs.
- *
- * Usage:
- *
- *
- *
- *
- *
- * @author Fabien Potencier
- * @author Kris Wallsmith
- *
- * @deprecated since 2.7, will be removed in 3.0. Use the Asset component instead.
- */
-class CoreAssetsHelper extends Helper implements PackageInterface
-{
- protected $defaultPackage;
- protected $namedPackages = array();
-
- /**
- * Constructor.
- *
- * @param PackageInterface $defaultPackage The default package
- * @param array $namedPackages Additional packages indexed by name
- */
- public function __construct(PackageInterface $defaultPackage, array $namedPackages = array())
- {
- $this->defaultPackage = $defaultPackage;
-
- foreach ($namedPackages as $name => $package) {
- $this->addPackage($name, $package);
- }
- }
-
- /**
- * Sets the default package.
- *
- * @param PackageInterface $defaultPackage The default package
- */
- public function setDefaultPackage(PackageInterface $defaultPackage)
- {
- $this->defaultPackage = $defaultPackage;
- }
-
- /**
- * Adds an asset package to the helper.
- *
- * @param string $name The package name
- * @param PackageInterface $package The package
- */
- public function addPackage($name, PackageInterface $package)
- {
- $this->namedPackages[$name] = $package;
- }
-
- /**
- * Returns an asset package.
- *
- * @param string $name The name of the package or null for the default package
- *
- * @return PackageInterface An asset package
- *
- * @throws \InvalidArgumentException If there is no package by that name
- */
- public function getPackage($name = null)
- {
- if (null === $name) {
- return $this->defaultPackage;
- }
-
- if (!isset($this->namedPackages[$name])) {
- throw new \InvalidArgumentException(sprintf('There is no "%s" asset package.', $name));
- }
-
- return $this->namedPackages[$name];
- }
-
- /**
- * Gets the version to add to public URL.
- *
- * @param string $packageName A package name
- *
- * @return string The current version
- */
- public function getVersion($packageName = null)
- {
- return $this->getPackage($packageName)->getVersion();
- }
-
- /**
- * Returns the public path.
- *
- * Absolute paths (i.e. http://...) are returned unmodified.
- *
- * @param string $path A public path
- * @param string $packageName The name of the asset package to use
- * @param string|bool|null $version A specific version
- *
- * @return string A public path which takes into account the base path and URL path
- */
- public function getUrl($path, $packageName = null, $version = null)
- {
- return $this->getPackage($packageName)->getUrl($path, $version);
- }
-
- /**
- * Returns the canonical name of this helper.
- *
- * @return string The canonical name
- */
- public function getName()
- {
- return 'assets';
- }
-}
diff --git a/src/Symfony/Component/Templating/Tests/Helper/LegacyAssetsHelperTest.php b/src/Symfony/Component/Templating/Tests/Helper/LegacyAssetsHelperTest.php
deleted file mode 100644
index a3e61fb9756f2..0000000000000
--- a/src/Symfony/Component/Templating/Tests/Helper/LegacyAssetsHelperTest.php
+++ /dev/null
@@ -1,78 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Symfony\Component\Templating\Tests\Helper;
-
-use Symfony\Component\Templating\Helper\AssetsHelper;
-
-class LegacyAssetsHelperTest extends \PHPUnit_Framework_TestCase
-{
- public function setUp()
- {
- $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
- }
-
- public function testGetVersion()
- {
- $helper = new AssetsHelper(null, array(), 'foo');
- $this->assertEquals('foo', $helper->getVersion(), '->getVersion() returns the version');
- }
-
- public function testGetUrl()
- {
- $helper = new AssetsHelper();
- $this->assertEquals('http://example.com/foo.js', $helper->getUrl('http://example.com/foo.js'), '->getUrl() does nothing if an absolute URL is given');
-
- $helper = new AssetsHelper();
- $this->assertEquals('/foo.js', $helper->getUrl('foo.js'), '->getUrl() appends a / on relative paths');
- $this->assertEquals('/foo.js', $helper->getUrl('/foo.js'), '->getUrl() does nothing on absolute paths');
-
- $helper = new AssetsHelper('/foo');
- $this->assertEquals('/foo/foo.js', $helper->getUrl('foo.js'), '->getUrl() appends the basePath on relative paths');
- $this->assertEquals('/foo.js', $helper->getUrl('/foo.js'), '->getUrl() does not append the basePath on absolute paths');
-
- $helper = new AssetsHelper(null, 'http://assets.example.com/');
- $this->assertEquals('http://assets.example.com/foo.js', $helper->getUrl('foo.js'), '->getUrl() prepends the base URL');
- $this->assertEquals('http://assets.example.com/foo.js', $helper->getUrl('/foo.js'), '->getUrl() prepends the base URL');
-
- $helper = new AssetsHelper(null, 'http://www.example.com/foo');
- $this->assertEquals('http://www.example.com/foo/foo.js', $helper->getUrl('foo.js'), '->getUrl() prepends the base URL with a path');
- $this->assertEquals('http://www.example.com/foo/foo.js', $helper->getUrl('/foo.js'), '->getUrl() prepends the base URL with a path');
-
- $helper = new AssetsHelper('/foo', 'http://www.example.com/');
- $this->assertEquals('http://www.example.com/foo.js', $helper->getUrl('foo.js'), '->getUrl() prepends the base URL and the base path if defined');
- $this->assertEquals('http://www.example.com/foo.js', $helper->getUrl('/foo.js'), '->getUrl() prepends the base URL but not the base path on absolute paths');
-
- $helper = new AssetsHelper('/bar', 'http://www.example.com/foo');
- $this->assertEquals('http://www.example.com/foo/foo.js', $helper->getUrl('foo.js'), '->getUrl() prepends the base URL and the base path if defined');
- $this->assertEquals('http://www.example.com/foo/foo.js', $helper->getUrl('/foo.js'), '->getUrl() prepends the base URL but not the base path on absolute paths');
-
- $helper = new AssetsHelper('/bar', 'http://www.example.com/foo', 'abcd');
- $this->assertEquals('http://www.example.com/foo/foo.js?abcd', $helper->getUrl('foo.js'), '->getUrl() appends the version if defined');
-
- $helper = new AssetsHelper();
- $this->assertEquals('/', $helper->getUrl(''), '->getUrl() with empty arg returns the prefix alone');
- }
-
- public function testGetUrlWithVersion()
- {
- $helper = new AssetsHelper(null, array(), '12');
- $this->assertEquals('/foo.js?12', $helper->getUrl('foo.js'));
- $this->assertEquals('/foo.js?bar', $helper->getUrl('foo.js', null, 'bar'));
- $this->assertEquals('/foo.js', $helper->getUrl('foo.js', null, false));
- }
-
- public function testGetUrlLeavesProtocolRelativePathsUntouched()
- {
- $helper = new AssetsHelper(null, 'http://foo.com');
- $this->assertEquals('//bar.com/asset', $helper->getUrl('//bar.com/asset'));
- }
-}
diff --git a/src/Symfony/Component/Templating/Tests/Helper/LegacyCoreAssetsHelperTest.php b/src/Symfony/Component/Templating/Tests/Helper/LegacyCoreAssetsHelperTest.php
deleted file mode 100644
index 65695ee6eb38f..0000000000000
--- a/src/Symfony/Component/Templating/Tests/Helper/LegacyCoreAssetsHelperTest.php
+++ /dev/null
@@ -1,56 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Symfony\Component\Templating\Tests\Helper;
-
-use Symfony\Component\Templating\Helper\CoreAssetsHelper;
-
-class LegacyCoreAssetsHelperTest extends \PHPUnit_Framework_TestCase
-{
- protected $package;
-
- protected function setUp()
- {
- $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
-
- $this->package = $this->getMock('Symfony\Component\Templating\Asset\PackageInterface');
- }
-
- protected function tearDown()
- {
- $this->package = null;
- }
-
- public function testAddGetPackage()
- {
- $helper = new CoreAssetsHelper($this->package);
-
- $helper->addPackage('foo', $this->package);
-
- $this->assertSame($this->package, $helper->getPackage('foo'));
- }
-
- public function testGetNonexistingPackage()
- {
- $helper = new CoreAssetsHelper($this->package);
-
- $this->setExpectedException('\InvalidArgumentException');
-
- $helper->getPackage('foo');
- }
-
- public function testGetHelperName()
- {
- $helper = new CoreAssetsHelper($this->package);
-
- $this->assertEquals('assets', $helper->getName());
- }
-}