Matthias Andreas Benkard | 12a5735 | 2021-12-28 18:02:04 +0100 | [diff] [blame^] | 1 | <?php |
| 2 | |
| 3 | /* |
| 4 | * This file is part of Twig. |
| 5 | * |
| 6 | * (c) Fabien Potencier |
| 7 | * |
| 8 | * For the full copyright and license information, please view the LICENSE |
| 9 | * file that was distributed with this source code. |
| 10 | */ |
| 11 | |
| 12 | namespace Twig\TokenParser; |
| 13 | |
| 14 | use Twig\Node\DeprecatedNode; |
| 15 | use Twig\Node\Node; |
| 16 | use Twig\Token; |
| 17 | |
| 18 | /** |
| 19 | * Deprecates a section of a template. |
| 20 | * |
| 21 | * {% deprecated 'The "base.twig" template is deprecated, use "layout.twig" instead.' %} |
| 22 | * {% extends 'layout.html.twig' %} |
| 23 | * |
| 24 | * @author Yonel Ceruto <yonelceruto@gmail.com> |
| 25 | * |
| 26 | * @internal |
| 27 | */ |
| 28 | final class DeprecatedTokenParser extends AbstractTokenParser |
| 29 | { |
| 30 | public function parse(Token $token): Node |
| 31 | { |
| 32 | $expr = $this->parser->getExpressionParser()->parseExpression(); |
| 33 | |
| 34 | $this->parser->getStream()->expect(Token::BLOCK_END_TYPE); |
| 35 | |
| 36 | return new DeprecatedNode($expr, $token->getLine(), $this->getTag()); |
| 37 | } |
| 38 | |
| 39 | public function getTag(): string |
| 40 | { |
| 41 | return 'deprecated'; |
| 42 | } |
| 43 | } |