Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
55 lines (45 sloc) 1.15 KB
<?php
/**
* @link https://craftcms.com/
* @copyright Copyright (c) Pixel & Tonic, Inc.
* @license https://craftcms.github.io/license/
*/
namespace craft\web\twig\tokenparsers;
use craft\web\twig\nodes\ExitNode;
use Twig\Parser;
use Twig\Token;
use Twig\TokenParser\AbstractTokenParser;
/**
* Class ExitTokenParser
*
* @author Pixel & Tonic, Inc. <support@pixelandtonic.com>
* @since 3.0.0
*/
class ExitTokenParser extends AbstractTokenParser
{
// Public Methods
// =========================================================================
/**
* @inheritdoc
*/
public function parse(Token $token)
{
$lineno = $token->getLine();
/** @var Parser $parser */
$parser = $this->parser;
$stream = $parser->getStream();
$nodes = [];
if ($stream->test(Token::NUMBER_TYPE)) {
$nodes['status'] = $parser->getExpressionParser()->parseExpression();
}
$stream->expect(Token::BLOCK_END_TYPE);
return new ExitNode($nodes, [], $lineno, $this->getTag());
}
/**
* @inheritdoc
*/
public function getTag()
{
return 'exit';
}
}
You can’t perform that action at this time.