1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the Superdesk Web Publisher Templates System. |
5
|
|
|
* |
6
|
|
|
* Copyright 2015 Sourcefabric z.ú. and contributors. |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please see the |
9
|
|
|
* AUTHORS and LICENSE files distributed with this source code. |
10
|
|
|
* |
11
|
|
|
* @copyright 2015 Sourcefabric z.ú |
12
|
|
|
* @license http://www.superdesk.org/license |
13
|
|
|
*/ |
14
|
|
|
|
15
|
|
|
namespace SWP\Component\TemplatesSystem\Twig\TokenParser; |
16
|
|
|
|
17
|
|
|
use SWP\Component\TemplatesSystem\Twig\Node\ContainerNode; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* @deprecated since 2.0, will be removed in 3.0 |
21
|
|
|
* Parser for container/endcontainer blocks. |
22
|
|
|
*/ |
23
|
|
|
class ContainerTokenParser extends \Twig\TokenParser\AbstractTokenParser |
24
|
|
|
{ |
25
|
|
|
/** |
26
|
|
|
* @param \Twig\Token $token |
27
|
|
|
* |
28
|
|
|
* @return bool |
29
|
|
|
*/ |
30
|
|
|
public function decideEnd(\Twig\Token $token) |
31
|
|
|
{ |
32
|
|
|
return $token->test('endcontainer'); |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* {@inheritdoc} |
37
|
|
|
*/ |
38
|
|
|
public function getTag() |
39
|
|
|
{ |
40
|
|
|
return 'container'; |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* {@inheritdoc} |
45
|
|
|
*/ |
46
|
|
|
public function parse(\Twig\Token $token) |
47
|
|
|
{ |
48
|
|
|
$lineno = $token->getLine(); |
49
|
|
|
$stream = $this->parser->getStream(); |
50
|
|
|
|
51
|
|
|
$name = $this->parser->getExpressionParser()->parseExpression(); |
52
|
|
|
|
53
|
|
|
$parameters = null; |
54
|
|
|
if ($stream->nextIf(\Twig\Token::NAME_TYPE, 'with')) { |
55
|
|
|
$parameters = $this->parser->getExpressionParser()->parseExpression(); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
$stream->expect(\Twig\Token::BLOCK_END_TYPE); |
59
|
|
|
$body = $this->parser->subparse([$this, 'decideEnd'], true); |
60
|
|
|
|
61
|
|
|
$stream->expect(\Twig\Token::BLOCK_END_TYPE); |
62
|
|
|
|
63
|
|
|
return new ContainerNode($name, $parameters, $body, $lineno, $this->getTag()); |
|
|
|
|
64
|
|
|
} |
65
|
|
|
} |
66
|
|
|
|
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.