aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/phpbb/template/twig/node/includeasset.php
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB/phpbb/template/twig/node/includeasset.php')
-rw-r--r--phpBB/phpbb/template/twig/node/includeasset.php32
1 files changed, 11 insertions, 21 deletions
diff --git a/phpBB/phpbb/template/twig/node/includeasset.php b/phpBB/phpbb/template/twig/node/includeasset.php
index 15195a226b..12034b7820 100644
--- a/phpBB/phpbb/template/twig/node/includeasset.php
+++ b/phpBB/phpbb/template/twig/node/includeasset.php
@@ -39,7 +39,7 @@ abstract class includeasset extends \Twig_Node
->write("\$asset_file = ")
->subcompile($this->getNode('expr'))
->raw(";\n")
- ->write("\$asset = new \phpbb\\template\\asset(\$asset_file, \$this->getEnvironment()->get_path_helper());\n")
+ ->write("\$asset = new \phpbb\\template\\asset(\$asset_file, \$this->getEnvironment()->get_path_helper(), \$this->getEnvironment()->get_filesystem());\n")
->write("if (substr(\$asset_file, 0, 2) !== './' && \$asset->is_relative()) {\n")
->indent()
->write("\$asset_path = \$asset->get_path();")
@@ -49,33 +49,23 @@ abstract class includeasset extends \Twig_Node
->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_file = \$asset->get_url();\n")
->write("}\n")
->outdent()
->write("}\n")
- ->write("\$context['definition']->append('{$this->get_definition_name()}', '")
- ;
-
- $this->append_asset($compiler);
-
- $compiler
- ->raw("\n');\n")
+ ->write("\n")
+ ->write("if (\$asset->is_relative()) {\n")
+ ->indent()
+ ->write("\$asset->add_assets_version('{$config['assets_version']}');\n")
+ ->outdent()
+ ->write("}\n")
+ ->write("\$this->getEnvironment()->get_assets_bag()->add_{$this->get_setters_name()}(\$asset);")
;
}
/**
- * Get the definition name
- *
- * @return string (e.g. 'SCRIPTS')
- */
- abstract public function get_definition_name();
-
- /**
- * Append the output code for the asset
+ * Get the name of the assets bag setter
*
- * @param \Twig_Compiler A Twig_Compiler instance
- * @return null
+ * @return string (e.g. 'script')
*/
- abstract protected function append_asset(\Twig_Compiler $compiler);
+ abstract public function get_setters_name();
}