Xpressengine\Presenter\Html\FrontendHandler::addTag PHP Method

addTag() public method

add tag
public addTag ( string $name, null | string $class = null ) : void
$name string name
$class null | string class name
return void
    public function addTag($name, $class = null)
    {
        if ($class !== null) {
            $name = [$name => $class];
        }
        $this->tags = array_merge($this->tags, $name);
    }

Usage Example

 public function testAddTagWithArray()
 {
     $frontend = new FrontendHandler();
     $tags = $this->getTagList();
     $frontend->addTag($tags);
     $refl = new \ReflectionObject($frontend);
     $reflTags = $refl->getProperty('tags');
     $reflTags->setAccessible(true);
     $this->assertEquals($tags, $reflTags->getValue($frontend));
 }