inject() public static method

Inject a new tag with a given name and a configurable array config.
public static inject ( string $name, string | array $config )
$name string The name of the tag on what the tag should be found. Must be [a-z] chars.
$config string | array The configurable object context can be either a string with a class or a configurable array base on yii\base\Object concept.
示例#1
0
 public function testInjectTag()
 {
     TagParser::inject('foo', ['class' => LinkTag::class]);
     $tags = TagParser::getInstantiatedTagObjects();
     $this->arrayHasKey('foo', $tags);
     $this->assertInstanceOf('luya\\tag\\tags\\LinkTag', $tags['foo']);
 }
示例#2
0
 /**
  * Before bootstrap run process.
  *
  * @see \luya\base\BaseBootstrap::beforeRun()
  */
 public function beforeRun($app)
 {
     foreach ($app->tags as $name => $config) {
         TagParser::inject($name, $config);
     }
     foreach ($this->getModules() as $id => $module) {
         foreach ($module->urlRules as $rule) {
             $this->_urlRules[isset($rule['position']) ? $rule['position'] : UrlRule::POSITION_AFTER_LUYA][] = $rule;
         }
         foreach ($module->apis as $alias => $class) {
             $this->_apis[$alias] = $class;
         }
         foreach ($module->tags as $name => $config) {
             TagParser::inject($name, $config);
         }
     }
 }