[ Index ]

PHP Cross Reference of phpBB-3.2.11-deutsch

title

Body

[close]

/phpbb/template/twig/node/ -> includeasset.php (source)

   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  
  14  namespace phpbb\template\twig\node;
  15  
  16  abstract class includeasset extends \Twig_Node
  17  {
  18      /** @var \Twig_Environment */
  19      protected $environment;
  20  
  21  	public function __construct(\Twig_Node_Expression $expr, \phpbb\template\twig\environment $environment, $lineno, $tag = null)
  22      {
  23          $this->environment = $environment;
  24  
  25          parent::__construct(array('expr' => $expr), array(), $lineno, $tag);
  26      }
  27      /**
  28      * Compiles the node to PHP.
  29      *
  30      * @param \Twig_Compiler A Twig_Compiler instance
  31      */
  32  	public function compile(\Twig_Compiler $compiler)
  33      {
  34          $compiler->addDebugInfo($this);
  35  
  36          $config = $this->environment->get_phpbb_config();
  37  
  38          $compiler
  39              ->write("\$asset_file = ")
  40              ->subcompile($this->getNode('expr'))
  41              ->raw(";\n")
  42              ->write("\$asset = new \phpbb\\template\\asset(\$asset_file, \$this->getEnvironment()->get_path_helper(), \$this->getEnvironment()->get_filesystem());\n")
  43              ->write("if (substr(\$asset_file, 0, 2) !== './' && \$asset->is_relative()) {\n")
  44              ->indent()
  45                  ->write("\$asset_path = \$asset->get_path();")
  46                  ->write("\$local_file = \$this->getEnvironment()->get_phpbb_root_path() . \$asset_path;\n")
  47                  ->write("if (!file_exists(\$local_file)) {\n")
  48                  ->indent()
  49                      ->write("\$local_file = \$this->getEnvironment()->findTemplate(\$asset_path);\n")
  50                      ->write("\$asset->set_path(\$local_file, true);\n")
  51                  ->outdent()
  52                  ->write("}\n")
  53              ->outdent()
  54              ->write("}\n")
  55              ->write("\n")
  56              ->write("if (\$asset->is_relative()) {\n")
  57              ->indent()
  58              ->write("\$asset->add_assets_version('{$config['assets_version']}');\n")
  59              ->outdent()
  60              ->write("}\n")
  61              ->write("\$this->getEnvironment()->get_assets_bag()->add_{$this->get_setters_name()}(\$asset);")
  62          ;
  63      }
  64  
  65      /**
  66      * Get the name of the assets bag setter
  67      *
  68      * @return string (e.g. 'script')
  69      */
  70      abstract public function get_setters_name();
  71  }


Generated: Wed Nov 11 20:33:01 2020 Cross-referenced by PHPXref 0.7.1