Skip to content
This repository has been archived by the owner on Jan 1, 2023. It is now read-only.

Commit

Permalink
Fixing deprecated notices from Twig 1.27
Browse files Browse the repository at this point in the history
  • Loading branch information
kubawerlos committed Nov 11, 2016
1 parent aa5b4f8 commit db798d2
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 22 deletions.
6 changes: 3 additions & 3 deletions Tests/Controller/AsseticControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ protected function setUp()
$this->markTestSkipped('Assetic is not available.');
}

$this->request = $this->getMock('Symfony\\Component\\HttpFoundation\\Request');
$this->request = $this->getMock('Symfony\\Component\\HttpFoundation\\Request', array('getETags', 'getMethod'));
$this->headers = $this->getMock('Symfony\\Component\\HttpFoundation\\ParameterBag');
$this->request->headers = $this->headers;
$this->am = $this->getMockBuilder('Assetic\\Factory\\LazyAssetManager')
Expand All @@ -36,8 +36,8 @@ protected function setUp()
$this->cache = $this->getMock('Assetic\\Cache\\CacheInterface');

$this->request->expects($this->any())
->method('isMethodSafe')
->will($this->returnValue(true));
->method('getMethod')
->willReturn('GET');

$this->controller = new AsseticController($this->am, $this->cache);
}
Expand Down
6 changes: 3 additions & 3 deletions Tests/Resources/config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ framework:
templating: { engines: ['twig', 'php'] }

twig:
debug: %kernel.debug%
strict_variables: %kernel.debug%
debug: '%kernel.debug%'
strict_variables: '%kernel.debug%'

assetic:
use_controller: true
Expand All @@ -27,7 +27,7 @@ assetic:
sass:
apply_to: '\.sass$'
yui_css:
jar: %kernel.root_dir/java/yui-compressor-2.4.6.jar
jar: '%kernel.root_dir/java/yui-compressor-2.4.6.jar'
twig:
functions:
yui_css: { output: css/*.css }
26 changes: 13 additions & 13 deletions Twig/AsseticNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,21 @@ protected function compileAssetUrl(\Twig_Compiler $compiler, AssetInterface $ass
{
$vars = array();
foreach ($asset->getVars() as $var) {
$vars[] = new \Twig_Node_Expression_Constant($var, $this->getLine());
$vars[] = new \Twig_Node_Expression_Constant($var, $this->getTemplateLine());

// Retrieves values of assetic vars from the context, $context['assetic']['vars'][$var].
$vars[] = new \Twig_Node_Expression_GetAttr(
new \Twig_Node_Expression_GetAttr(
new \Twig_Node_Expression_Name('assetic', $this->getLine()),
new \Twig_Node_Expression_Constant('vars', $this->getLine()),
new \Twig_Node_Expression_Array(array(), $this->getLine()),
new \Twig_Node_Expression_Name('assetic', $this->getTemplateLine()),
new \Twig_Node_Expression_Constant('vars', $this->getTemplateLine()),
new \Twig_Node_Expression_Array(array(), $this->getTemplateLine()),
\Twig_Template::ARRAY_CALL,
$this->getLine()
$this->getTemplateLine()
),
new \Twig_Node_Expression_Constant($var, $this->getLine()),
new \Twig_Node_Expression_Array(array(), $this->getLine()),
new \Twig_Node_Expression_Constant($var, $this->getTemplateLine()),
new \Twig_Node_Expression_Array(array(), $this->getTemplateLine()),
\Twig_Template::ARRAY_CALL,
$this->getLine()
$this->getTemplateLine()
);
}
$compiler
Expand All @@ -52,16 +52,16 @@ protected function compileAssetUrl(\Twig_Compiler $compiler, AssetInterface $ass

private function getPathFunction($name, array $vars = array())
{
$nodes = array(new \Twig_Node_Expression_Constant('_assetic_'.$name, $this->getLine()));
$nodes = array(new \Twig_Node_Expression_Constant('_assetic_'.$name, $this->getTemplateLine()));

if (!empty($vars)) {
$nodes[] = new \Twig_Node_Expression_Array($vars, $this->getLine());
$nodes[] = new \Twig_Node_Expression_Array($vars, $this->getTemplateLine());
}

return new \Twig_Node_Expression_Function(
'path',
new \Twig_Node($nodes),
$this->getLine()
$this->getTemplateLine()
);
}

Expand All @@ -70,13 +70,13 @@ private function getAssetFunction($path)
$arguments = array($path);

if ($this->hasAttribute('package')) {
$arguments[] = new \Twig_Node_Expression_Constant($this->getAttribute('package'), $this->getLine());
$arguments[] = new \Twig_Node_Expression_Constant($this->getAttribute('package'), $this->getTemplateLine());
}

return new \Twig_Node_Expression_Function(
'asset',
new \Twig_Node($arguments),
$this->getLine()
$this->getTemplateLine()
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion Twig/AsseticTokenParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function parse(\Twig_Token $token)
// check the bundle
$templateRef = null;
try {
$templateRef = $this->templateNameParser->parse($this->parser->getStream()->getFilename());
$templateRef = $this->templateNameParser->parse($this->parser->getStream()->getSourceContext()->getName());
} catch (\RuntimeException $e) {
// this happens when the filename isn't a Bundle:* url
// and it contains ".."
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"symfony/dependency-injection": "~2.3|~3.0",
"symfony/console": "~2.3|~3.0",
"symfony/yaml": "~2.3|~3.0",
"kriswallsmith/assetic": "~1.3"
"kriswallsmith/assetic": "~1.4"
},
"require-dev": {
"patchwork/jsqueeze": "~1.0",
Expand All @@ -30,7 +30,7 @@
"symfony/phpunit-bridge": "~2.7|~3.0"
},
"conflict": {
"twig/twig": "<1.20",
"twig/twig": "<1.27",
"kriswallsmith/spork": "<=0.2"
},
"suggest": {
Expand Down

0 comments on commit db798d2

Please sign in to comment.