ExtendsAdmingeneratedTokenParser::parse()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 17
rs 9.7
c 0
b 0
f 0
cc 2
nc 2
nop 1
1
<?php
2
3
namespace Admingenerator\GeneratorBundle\Twig\TokenParser;
4
5
class ExtendsAdmingeneratedTokenParser extends \Twig_TokenParser
0 ignored issues
show
Deprecated Code introduced by
The class Twig_TokenParser has been deprecated with message: since Twig 2.7, use "Twig\TokenParser\AbstractTokenParser" instead

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
6
{
7
8
    /**
9
     * Parses a token and returns a node.
10
     *
11
     * @param \Twig_Token $token A \Twig_Token instance
12
     *
13
     * @return \Twig_NodeInterface A \Twig_NodeInterface instance
14
     */
15
    public function parse(\Twig_Token $token)
16
    {
17
        if (null !== $this->parser->getParent()) {
18
            throw new \Twig_Error_Syntax('Multiple extends tags are forbidden', $token->getLine());
0 ignored issues
show
Deprecated Code introduced by
The class Twig_Error_Syntax has been deprecated with message: since Twig 2.7, use "Twig\Error\SyntaxError" instead

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
19
        }
20
21
        list($bundle, $folder, $file) = explode(':', $this->parser->getCurrentToken()->getValue());
22
23
        $path = "Admingenerated/$bundle/Resources/views/$folder/$file";
24
25
        $this->parser->getExpressionParser()->parseExpression();
26
27
        $this->parser->setParent(new \Twig_Node_Expression_Constant($path,$token->getLine()));
0 ignored issues
show
Deprecated Code introduced by
The class Twig_Node_Expression_Constant has been deprecated with message: since Twig 2.7, use "Twig\Node\Expression\ConstantExpression" instead

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
28
        $this->parser->getStream()->expect(\Twig_Token::BLOCK_END_TYPE);
29
30
        return null;
31
    }
32
33
    /**
34
     * Gets the tag name associated with this token parser.
35
     *
36
     * @return string The tag name
37
     */
38
    public function getTag()
39
    {
40
        return 'extends_admingenerated';
41
    }
42
}
43