Skip to content

Commit

Permalink
Remove deprecated getGlobals
Browse files Browse the repository at this point in the history
  • Loading branch information
eschmar committed Apr 25, 2016
1 parent 5bfb287 commit e59366e
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 49 deletions.
17 changes: 0 additions & 17 deletions Tests/Controller/DefaultControllerTest.php

This file was deleted.

27 changes: 3 additions & 24 deletions Twig/CssInlinerExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,46 +8,25 @@
* Twig Extension containing the CssInliner Twig tag.
*
* @package default
* @author Marcel Eschmann
* @author Marcel Eschmann, @eschmar
**/
class CssInlinerExtension extends \Twig_Extension {

/**
* Returns the name of the extension.
*
* @return string
* @author Marcel Eschmann
* @author Marcel Eschmann, @eschmar
**/
public function getName() {
return 'css_inliner_extension';
}

/**
* Returns a list of global variables to add to the existing list.
*
* @return void
* @author Marcel Eschmann
**/
public function getGlobals() {
return array (
/**
* Actual css inliner implementation.
**/
'inliner' => function($input) {
$inliner = new CssToInlineStyles();
$inliner->setHTML($input);
$inliner->setUseInlineStylesBlock();
$inliner->setStripOriginalStyleTags();
return $inliner->convert();
}
);
}

/**
* Returns the token parser instances to add to the existing list.
*
* @return array(Twig_Node)
* @author Marcel Eschmann
* @author Marcel Eschmann, @eschmar
**/
public function getTokenParsers() {
return array(
Expand Down
13 changes: 9 additions & 4 deletions Twig/CssInlinerNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
* Responsible for processing the current node.
*
* @package default
* @author Marcel Eschmann
* @author Marcel Eschmann, @eschmar
**/
class CssInlinerNode extends \Twig_Node {

/**
* @return void
* @author Marcel Eschmann
* @author Marcel Eschmann, @eschmar
**/
public function __construct(\Twig_NodeInterface $body, $lineno, $tag = 'cssinline') {
parent::__construct(array('body' => $body), array(), $lineno, $tag);
Expand All @@ -22,14 +22,19 @@ public function __construct(\Twig_NodeInterface $body, $lineno, $tag = 'cssinlin
* Directly outputs the processed node.
*
* @return string
* @author Marcel Eschmann
* @author Marcel Eschmann, @eschmar
**/
public function compile(\Twig_Compiler $compiler) {
$compiler
->addDebugInfo($this)
->write("ob_start();\n")
->subcompile($this->getNode('body'))
->write('echo $context["inliner"](ob_get_clean());' . "\n");

->write("\$inliner = new TijsVerkoyen\\CssToInlineStyles\\CssToInlineStyles(); \n")
->write("\$inliner->setHTML(ob_get_clean()); \n")
->write("\$inliner->setUseInlineStylesBlock(); \n")
->write("\$inliner->setStripOriginalStyleTags(); \n")
->write("echo \$inliner->convert(); \n");
}

} // END class CssInlinerNode extends \Twig_Node
8 changes: 4 additions & 4 deletions Twig/CssInlinerTokenParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
* Responsible for recognizing the cssinline tag.
*
* @package default
* @author Marcel Eschmann
* @author Marcel Eschmann, @eschmar
**/
class CssInlinerTokenParser extends \Twig_TokenParser {

/**
* Is invoked whenever the parser encounters a cssinline tag.
*
* @return CssInlinerNode
* @author Marcel Eschmann
* @author Marcel Eschmann, @eschmar
**/
public function parse(\Twig_Token $token) {
//$path = $this->parser->getStream()->expect(Twig_Token::STRING_TYPE)->getValue();
Expand All @@ -28,7 +28,7 @@ public function parse(\Twig_Token $token) {
* Defines the name of the ending twig block.
*
* @return boolean
* @author Marcel Eschmann
* @author Marcel Eschmann, @eschmar
**/
public function decideCssInlineEnd(\Twig_Token $token) {
return $token->test('endcssinline');
Expand All @@ -38,7 +38,7 @@ public function decideCssInlineEnd(\Twig_Token $token) {
* Returns the name of the tag.
*
* @return string
* @author Marcel Eschmann
* @author Marcel Eschmann, @eschmar
**/
public function getTag() {
return 'cssinline';
Expand Down

0 comments on commit e59366e

Please sign in to comment.