Пример #1
0
 /**
  * Set the attributes
  *
  * @param \TYPO3\CMS\Form\Domain\Model\Element\AbstractElement $element Model object
  * @param array $arguments Arguments
  * @return void
  */
 public function setAttributes(\TYPO3\CMS\Form\Domain\Model\Element\AbstractElement $element, array $arguments)
 {
     if ($element->hasAllowedAttributes()) {
         $attributes = $element->getAllowedAttributes();
         $mandatoryAttributes = $element->getMandatoryAttributes();
         foreach ($attributes as $attribute => $value) {
             if (isset($arguments[$attribute]) || isset($arguments[$attribute . '.']) || in_array($attribute, $mandatoryAttributes) || !empty($value)) {
                 if (!empty($arguments[$attribute])) {
                     $value = $arguments[$attribute];
                 } elseif (!empty($arguments[$attribute . '.'])) {
                     $value = $arguments[$attribute . '.'];
                 }
                 try {
                     $element->setAttribute($attribute, $value);
                 } catch (\Exception $exception) {
                     throw new \RuntimeException('Cannot call user function for attribute ' . ucfirst($attribute), 1333754904);
                 }
             }
         }
     } else {
         throw new \InvalidArgumentException('The element with id=' . $element->getElementId() . ' has no default attributes set.', 1333754925);
     }
 }