/** * Sets the tag name to $this->tagName. * Additionally, sets all tag attributes which were registered in * $this->tagAttributes and additionalArguments. * * Will be invoked just before the render method. * * @return void * @author Bastian Waidelich <*****@*****.**> * @api */ public function initialize() { parent::initialize(); $this->tag->reset(); $this->tag->setTagName($this->tagName); if (is_array($this->arguments['additionalAttributes'])) { $this->tag->addAttributes($this->arguments['additionalAttributes']); } foreach ($this->tagAttributes as $attributeName) { if ($this->arguments->hasArgument($attributeName) && $this->arguments[$attributeName] !== '') { $this->tag->addAttribute($attributeName, $this->arguments[$attributeName]); } } }
/** * @test * @author Bastian Waidelich <*****@*****.**> */ public function attributesCanBeRemoved() { $tagBuilder = new Tx_Fluid_Core_ViewHelper_TagBuilder('tag'); $tagBuilder->addAttribute('attribute1', 'attribute1value'); $tagBuilder->addAttribute('attribute2', 'attribute2value'); $tagBuilder->addAttribute('attribute3', 'attribute3value'); $tagBuilder->removeAttribute('attribute2'); $this->assertEquals('<tag attribute1="attribute1value" attribute3="attribute3value" />', $tagBuilder->render()); }