Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
13 / 13
100.00% covered (success)
100.00%
3 / 3
CRAP
100.00% covered (success)
100.00%
1 / 1
event
100.00% covered (success)
100.00%
13 / 13
100.00% covered (success)
100.00%
3 / 3
4
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
8 / 8
100.00% covered (success)
100.00%
1 / 1
2
 parse
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
1
 getTag
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2/**
3*
4* This file is part of the phpBB Forum Software package.
5*
6* @copyright (c) phpBB Limited <https://www.phpbb.com>
7* @license GNU General Public License, version 2 (GPL-2.0)
8*
9* For full copyright and license information, please see
10* the docs/CREDITS.txt file.
11*
12*/
13
14namespace phpbb\template\twig\tokenparser;
15
16class event extends \Twig\TokenParser\AbstractTokenParser
17{
18    /** @var \phpbb\template\twig\environment */
19    protected $environment;
20
21    /** @var array */
22    protected $template_event_priority_array;
23
24    /**
25    * Constructor
26    *
27    * @param \phpbb\template\twig\environment $environment
28    */
29    public function __construct(\phpbb\template\twig\environment $environment)
30    {
31        $this->environment = $environment;
32        $phpbb_dispatcher = $this->environment->get_phpbb_dispatcher();
33
34        $template_event_priority_array = [];
35        /**
36         * Allows assigning priority to template event listeners
37         *
38         * @event core.twig_event_tokenparser_constructor
39         * @var    array    template_event_priority_array    Array with template event priority assignments per extension namespace
40         *
41         * @since 4.0.0-a1
42         */
43        if ($phpbb_dispatcher)
44        {
45            $vars = ['template_event_priority_array'];
46            extract($phpbb_dispatcher->trigger_event('core.twig_event_tokenparser_constructor', compact($vars)));
47        }
48
49        $this->template_event_priority_array = $template_event_priority_array;
50        unset($template_event_priority_array);
51    }
52
53    /**
54    * Parses a token and returns a node.
55    *
56    * @param \Twig\Token $token A Twig\Token instance
57    *
58    * @return \Twig\Node\Node A Twig\Node instance
59    */
60    public function parse(\Twig\Token $token)
61    {
62        $expr = $this->parser->getExpressionParser()->parseExpression();
63
64        $stream = $this->parser->getStream();
65        $stream->expect(\Twig\Token::BLOCK_END_TYPE);
66
67        return new \phpbb\template\twig\node\event($expr, $this->environment, $token->getLine(), $this->getTag(), $this->template_event_priority_array);
68    }
69
70    /**
71    * Gets the tag name associated with this token parser.
72    *
73    * @return string The tag name
74    */
75    public function getTag()
76    {
77        return 'EVENT';
78    }
79}