Exemplo n.º 1
0
 /**
  * Handles additional arguments, sorting out any data-
  * prefixed tag attributes and assigning them. Then passes
  * the unassigned arguments to the parent class' method,
  * which in the default implementation will throw an error
  * about "undeclared argument used".
  *
  * @param array $arguments
  * @return void
  */
 public function handleAdditionalArguments(array $arguments)
 {
     $unassigned = array();
     foreach ($arguments as $argumentName => $argumentValue) {
         if (strpos($argumentName, 'data-') === 0) {
             $this->tag->addAttribute($argumentName, $argumentValue);
         } else {
             $unassigned[$argumentName] = $argumentValue;
         }
     }
     parent::handleAdditionalArguments($unassigned);
 }
Exemplo n.º 2
0
 /**
  * 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
  * @api
  */
 public function initialize()
 {
     parent::initialize();
     $this->tag->reset();
     $this->tag->setTagName($this->tagName);
     if ($this->hasArgument('additionalAttributes') && is_array($this->arguments['additionalAttributes'])) {
         $this->tag->addAttributes($this->arguments['additionalAttributes']);
     }
     if ($this->hasArgument('data') && is_array($this->arguments['data'])) {
         foreach ($this->arguments['data'] as $dataAttributeKey => $dataAttributeValue) {
             $this->tag->addAttribute('data-' . $dataAttributeKey, $dataAttributeValue);
         }
     }
     if (isset(self::$tagAttributes[get_class($this)])) {
         foreach (self::$tagAttributes[get_class($this)] as $attributeName) {
             if ($this->hasArgument($attributeName) && $this->arguments[$attributeName] !== '') {
                 $this->tag->addAttribute($attributeName, $this->arguments[$attributeName]);
             }
         }
     }
 }