diff options
Diffstat (limited to 'phpBB/phpbb/template/twig/node')
| -rw-r--r-- | phpBB/phpbb/template/twig/node/event.php | 8 | ||||
| -rw-r--r-- | phpBB/phpbb/template/twig/node/includeasset.php | 21 | ||||
| -rw-r--r-- | phpBB/phpbb/template/twig/node/includecss.php | 11 | ||||
| -rw-r--r-- | phpBB/phpbb/template/twig/node/includejs.php | 11 |
4 files changed, 37 insertions, 14 deletions
diff --git a/phpBB/phpbb/template/twig/node/event.php b/phpBB/phpbb/template/twig/node/event.php index a55e68fb04..1fc85ab4a2 100644 --- a/phpBB/phpbb/template/twig/node/event.php +++ b/phpBB/phpbb/template/twig/node/event.php @@ -20,6 +20,12 @@ if (!defined('IN_PHPBB')) class event extends \Twig_Node { + /** + * The subdirectory in which all template listener files must be placed + * @var string + */ + protected $listener_directory = 'event/'; + /** @var Twig_Environment */ protected $environment; @@ -39,7 +45,7 @@ class event extends \Twig_Node { $compiler->addDebugInfo($this); - $location = $this->getNode('expr')->getAttribute('name'); + $location = $this->listener_directory . $this->getNode('expr')->getAttribute('name'); foreach ($this->environment->get_phpbb_extensions() as $ext_namespace => $ext_path) { diff --git a/phpBB/phpbb/template/twig/node/includeasset.php b/phpBB/phpbb/template/twig/node/includeasset.php index 3c899b96e8..d632469c9e 100644 --- a/phpBB/phpbb/template/twig/node/includeasset.php +++ b/phpBB/phpbb/template/twig/node/includeasset.php @@ -9,7 +9,7 @@ namespace phpbb\template\twig\node; -class includeasset extends \Twig_Node +abstract class includeasset extends \Twig_Node { /** @var Twig_Environment */ protected $environment; @@ -42,10 +42,10 @@ class includeasset extends \Twig_Node ->write("\$local_file = \$this->getEnvironment()->get_phpbb_root_path() . \$asset_path;\n") ->write("if (!file_exists(\$local_file)) {\n") ->indent() - ->write("\$local_file = \$this->getEnvironment()->getLoader()->getCacheKey(\$asset_path);\n") + ->write("\$local_file = \$this->getEnvironment()->findTemplate(\$asset_path);\n") ->write("\$asset->set_path(\$local_file, true);\n") ->outdent() - ->write("\$asset->add_assets_version({$config['assets_version']});\n") + ->write("\$asset->add_assets_version('{$config['assets_version']}');\n") ->write("\$asset_file = \$asset->get_url();\n") ->write("}\n") ->outdent() @@ -59,4 +59,19 @@ class includeasset extends \Twig_Node ->raw("\n');\n") ; } + + /** + * Get the definition name + * + * @return string (e.g. 'SCRIPTS') + */ + abstract public function get_definition_name(); + + /** + * Append the output code for the asset + * + * @param Twig_Compiler A Twig_Compiler instance + * @return null + */ + abstract protected function append_asset(Twig_Compiler $compiler); } diff --git a/phpBB/phpbb/template/twig/node/includecss.php b/phpBB/phpbb/template/twig/node/includecss.php index 45ff9107a0..9601cc5155 100644 --- a/phpBB/phpbb/template/twig/node/includecss.php +++ b/phpBB/phpbb/template/twig/node/includecss.php @@ -11,17 +11,18 @@ namespace phpbb\template\twig\node; class includecss extends \phpbb\template\twig\node\includeasset { + /** + * {@inheritdoc} + */ public function get_definition_name() { return 'STYLESHEETS'; } /** - * Compiles the node to PHP. - * - * @param Twig_Compiler A Twig_Compiler instance - */ - public function append_asset(\Twig_Compiler $compiler) + * {@inheritdoc} + */ + public function append_asset(Twig_Compiler $compiler) { $compiler ->raw("<link href=\"' . ") diff --git a/phpBB/phpbb/template/twig/node/includejs.php b/phpBB/phpbb/template/twig/node/includejs.php index 7b400d9154..510e221e07 100644 --- a/phpBB/phpbb/template/twig/node/includejs.php +++ b/phpBB/phpbb/template/twig/node/includejs.php @@ -11,17 +11,18 @@ namespace phpbb\template\twig\node; class includejs extends \phpbb\template\twig\node\includeasset { + /** + * {@inheritdoc} + */ public function get_definition_name() { return 'SCRIPTS'; } /** - * Compiles the node to PHP. - * - * @param Twig_Compiler A Twig_Compiler instance - */ - protected function append_asset(\Twig_Compiler $compiler) + * {@inheritdoc} + */ + protected function append_asset(Twig_Compiler $compiler) { $config = $this->environment->get_phpbb_config(); |
