8000 feature #13666 removed deprecated asset feature (fabpot) · symfony/symfony@d948837 · GitHub
[go: up one dir, main page]

Skip to content

Commit d948837

Browse files
committed
feature #13666 removed deprecated asset feature (fabpot)
This PR was merged into the 3.0-dev branch. Discussion ---------- removed deprecated asset feature | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | n/a | License | MIT | Doc PR | n/a Commits ------- 52badd0 removed deprecated Twig features 8018d4b removed deprecated asset feature
2 parents bdd1ed2 + 52badd0 commit d948837

28 files changed

+24
-1710
lines changed

src/Symfony/Bridge/Twig/Extension/AssetExtension.php

Lines changed: 2 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
namespace Symfony\Bridge\Twig\Extension;
1313

1414
use Symfony\Component\Asset\Packages;
15-
use Symfony\Component\Asset\VersionStrategy\StaticVersionStrategy;
1615

1716
/**
1817
* Twig extension for the Symfony Asset component.
@@ -22,16 +21,10 @@
2221
class AssetExtension extends \Twig_Extension
2322
{
2423
private $packages;
25-
private $foundationExtension;
2624

27-
/**
28-
* Passing an HttpFoundationExtension instance as a second argument must not be relied on
29-
* as it's only there to maintain BC with older Symfony version. It will be removed in 3.0.
30-
*/
31-
public function __construct(Packages $packages, HttpFoundationExtension $foundationExtension = null)
25+
public function __construct(Packages $packages)
3226
{
3327
$this->packages = $packages;
34-
$this->foundationExtension = $foundationExtension;
3528
}
3629

3730
/**
@@ -42,7 +35,6 @@ public function getFunctions()
4235
return array(
4336
new \Twig_SimpleFunction('asset', array($this, 'getAssetUrl')),
4437
new \Twig_SimpleFunction('asset_version', array($this, 'getAssetVersion')),
45-
new \Twig_SimpleFunction('assets_version', array($this, 'getAssetsVersion')),
4638
);
4739
}
4840

@@ -57,20 +49,8 @@ public function getFunctions()
5749
*
5850
* @return string The public path of the asset
5951
*/
60-
public function getAssetUrl($path, $packageName = null, $absolute = false, $version = null)
52+
public function getAssetUrl($path, $packageName = null)
6153
{
62-
// BC layer to be removed in 3.0
63-
if (2 < $count = func_num_args()) {
64-
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);
65-
if (4 === $count) {
66-
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);
67-
}
68-
69-
$args = func_get_args();
70-
71-
return $this->getLegacyAssetUrl($path, $packageName, $args[2], isset($args[3]) ? $args[3] : null);
72-
}
73-
7454
return $this->packages->getUrl($path, $packageName);
7555
}
7656

@@ -87,51 +67,6 @@ public function getAssetVersion($path, $packageName = null)
8767
return $this->packages->getVersion($path, $packageName);
8868
}
8969

90-
public function getAssetsVersion($packageName = null)
91-
{
92-
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);
93-
94-
return $this->packages->getVersion('/', $packageName);
95-
}
96-
97-
private function getLegacyAssetUrl($path, $packageName = null, $absolute = false, $version = null)
98-
{
99-
if ($version) {
100-
$package = $this->packages->getPackage($packageName);
101-
102-
$v = new \ReflectionProperty($package, 'versionStrategy');
103-
$v->setAccessible(true);
104-
105-
$currentVersionStrategy = $v->getValue($package);
106-
107-
$f = new \ReflectionProperty($currentVersionStrategy, 'format');
108-
$f->setAccessible(true);
109-
$format = $f->getValue($currentVersionStrategy);
110-
111-
$v->setValue($package, new StaticVersionStrategy($version, $format));
112-
}
113-
114-
try {
115-
$url = $this->packages->getUrl($path, $packageName);
116-
} catch (\Exception $e) {
117-
if ($version) {
118-
$v->setValue($package, $currentVersionStrategy);
119-
}
120-
121-
throw $e;
122-
}
123-
124-
if ($version) {
125-
$v->setValue($package, $currentVersionStrategy);
126-
}
127-
128-
if ($absolute) {
129-
return $this->foundationExtension->generateAbsoluteUrl($url);
130-
}
131-
132-
return $url;
133-
}
134-
13570
/**
13671
* Returns the name of the extension.
13772
*

src/Symfony/Bridge/Twig/Tests/Extension/AssetExtensionTest.php

Lines changed: 0 additions & 40 deletions
This file was deleted.

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/TemplatingAssetHelperPass.php

Lines changed: 0 additions & 71 deletions
This file was deleted.

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php

Lines changed: 1 addition & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -53,44 +53,6 @@ public function getConfigTreeBuilder()
5353
return $v;
5454
})
5555
->end()
56-
->validate()
57-
->ifTrue(function ($v) { return isset($v['templating']); })
58-
->then(function ($v) {
59-
if ($v['templating']['assets_version']
60-
|| count($v['templating']['assets_base_urls']['http'])
61-
|| count($v['templating']['assets_base_urls']['ssl'])
62-
|| count($v['templating']['packages'])
63-
) {
64-
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);
65-
66-
// convert the old configuration to the new one
67-
if (isset($v['assets'])) {
68-
throw new LogicException('You cannot use assets settings under "templating.templating" and "assets" configurations in the same project.');
69-
}
70-
71-
$v['assets'] = array(
72-
'version' => $v['templating']['assets_version'],
73-
'version_format' => $v['templating']['assets_version_format'],
74-
'base_path' => '',
75-
'base_urls' => array_values(array_unique(array_merge($v['templating']['assets_base_urls']['http'], $v['templating']['assets_base_urls']['ssl']))),
76-
'packages' => array(),
77-
);
78-
79-
foreach ($v['templating']['packages'] as $name => $config) {
80-
$v['assets']['packages'][$name] = array(
81-
'version' => (string) $config['version'],
82-
'version_format' => $config['version_format'],
83-
'base_path' => '',
84-
'base_urls' => array_values(array_unique(array_merge($config['base_urls']['http'], $config['base_urls']['ssl']))),
85-
);
86-
}
87-
}
88-
89-
unset($v['templating']['assets_version'], $v['templating']['assets_version_format'], $v['templating']['assets_base_urls'], $v['templating']['packages']);
90-
91-
return $v;
92-
})
93-
->end()
9456
->children()
9557
->scalarNode('secret')->end()
9658
->scalarNode('http_method_override')
@@ -360,35 +322,14 @@ private function addRequestSection(ArrayNodeDefinition $rootNode)
360322

361323
private function addTemplatingSection(ArrayNodeDefinition $rootNode)
362324
{
363-
$organizeUrls = function ($urls) {
364-
$urls += array(
365-
'http' => array(),
366-
'ssl' => array(),
367-
);
368-
369-
foreach ($urls as $i => $url) {
370-
if (is_integer($i)) {
371-
if (0 === strpos($url, 'https://') || 0 === strpos($url, '//')) {
372-
$urls['http'][] = $urls['ssl'][] = $url;
373-
} else {
374-
$urls['http'][] = $url;
375-
}
376-
unset($urls[$i]);
377-
}
378-
}
379-
380-
return $urls;
381-
};
382-
383325
$rootNode
384326
->children()
385327
->arrayNode('templating')
386328
->info('templating configuration')
387329
->canBeUnset()
388330
->children()
389-
->scalarNode('assets_version')->defaultNull()->info('Deprecated since 2.7, will be removed in 3.0. Use the new assets entry instead.')->end()
390-
->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()
391331
->scalarNode('hinclude_default_template')->defaultNull()->end()
332+
->scalarNode('cache')->end()
392333
->arrayNode('form')
393334
->addDefaultsIfNotSet()
394335
->fixXmlConfig('resource')
@@ -406,31 +347,6 @@ private function addTemplatingSection(ArrayNodeDefinition $rootNode)
406347
->end()
407348
->end()
408349
->end()
409-
->fixXmlConfig('assets_base_url')
410-
->children()
411-
->arrayNode('assets_base_urls')
412-
->info('Deprecated since 2.7, will be removed in 3.0. Use the new assets entry instead.')
413-
->performNoDeepMerging()
414-
->addDefaultsIfNotSet()
415-
->beforeNormalization()
416-
->ifTrue(function ($v) { return !is_array($v); })
417-
->then(function ($v) { return array($v); })
418-
->end()
419-
->beforeNormalization()
420-
->always()
421-
->then($organizeUrls)
422-
->end()
423-
->children()
424-
->arrayNode('http')
425-
->prototype('scalar')->end()
426-
->end()
427-
->arrayNode('ssl')
428-
->prototype('scalar')->end()
429-
->end()
430-
->end()
431-
->end()
432-
->scalarNode('cache')->end()
433-
->end()
434350
->fixXmlConfig('engine')
435351
->children()
436352
->arrayNode('engines')
@@ -454,40 +370,6 @@ private function addTemplatingSection(ArrayNodeDefinition $rootNode)
454370
->prototype('scalar')->end()
455371
->end()
456372
->end()
457-
->fixXmlConfig('package')
458-
->children()
459-
->arrayNode('packages')
460-
->info('Deprecated since 2.7, will be removed in 3.0. Use the new assets entry instead.')
461-
->useAttributeAsKey('name')
462-
->prototype('array')
463-
->fixXmlConfig('base_url')
464-
->children()
465-
->scalarNode('version')->defaultNull()->end()
466-
->scalarNode('version_format')->defaultValue('%%s?%%s')->end()
467-
->arrayNode('base_urls')
468-
->performNoDeepMerging()
469-
->addDefaultsIfNotSet()
470-
->beforeNormalization()
471-
->ifTrue(function ($v) { return !is_array($v); })
472-
->then(function ($v) { return array($v); })
473-
->end()
474-
->beforeNormalization()
475-
->always()
476-
->then($organizeUrls)
477-
->end()
478-
->children()
479-
->arrayNode('http')
480-
->prototype('scalar')->end()
481-
->end()
482-
->arrayNode('ssl')
483-
->prototype('scalar')->end()
484-
->end()
485-
->end()
486-
->end()
487-
->end()
488-
->end()
489-
->end()
490-
->end()
491373
->end()
492374
->end()
493375
;

0 commit comments

Comments
 (0)
0