Method will automatically mount requested uses is any.

@param DeclarationInterface $element

@return self
@throws Exception\ReactorException
189072
public function addElement(DeclarationInterface $element): NamespaceDeclaration
    {
        $this->elements->add($element);
        if ($element instanceof DependedInterface) {
            $this->addUses($element->getDependencies());
        }

        return $this;
    }
714494
public function replaceWith(Element $element) 
	{
		// if the element has a parent
		if ( ! empty($this->parent)) {
			$this->parent->replaceChild($this, $element);
		} else {
			throw new \BadMethodCallException(
				__METHOD__."() expects this element to have a parent element"
			);
		}
		
		return $this;
	}
349435
public function render(ElementInterface $element)
    {
        $captcha = $element->getCaptcha();

        if ($captcha === null || !$captcha instanceof CaptchaAdapter) {
            throw new Exception\DomainException(sprintf(
                '%s requires that the element has a "captcha" attribute of type Zend\Captcha\Image; none found',
                __METHOD__
            ));
        }

        $captcha->generate();

        $imgAttributes = array(
            'width'  => $captcha->getWidth(),
            'height' => $captcha->getHeight(),
            'alt'    => $captcha->getImgAlt(),
            'src'    => $captcha->getImgUrl() . $captcha->getId() . $captcha->getSuffix(),
        );

        if ($element->hasAttribute('id')) {
            $imgAttributes['id'] = $element->getAttribute('id') . '-image';
        }

        $closingBracket = $this->getInlineClosingBracket();
        $img = sprintf(
            '<img %s%s',
            $this->createAttributesString($imgAttributes),
            $closingBracket
        );

        $position     = $this->getCaptchaPosition();
        $separator    = $this->getSeparator();
        $captchaInput = $this->renderCaptchaInputs($element);

        $pattern = '<div style="float:left;" class="form-captcha-image">%s%s</div><div class="form-captcha-input" style="margin-left:' . $imgAttributes['width'] . 'px">%s</div>';
        if ($position == self::CAPTCHA_PREPEND) {
            return sprintf($pattern, $captchaInput, $separator, $img);
        }
        return sprintf($pattern, $img, $separator, $captchaInput);
    }
102024
public function add(Interceptor $element)
    {
        if ($this->next) {
            $this->next->add($element);
        } else {
            $this->next = $element;
        }

        return $this;
    }
42497
private function validate($element)
    {
        $violationList = $this->validator->validate($element, null, ['Generator']);
        if (0 < $violationList->count()) {
            $this->output->writeln('<error>Invalid element</error>');
            /** @var \Symfony\Component\Validator\ConstraintViolationInterface $violation */
            foreach ($violationList as $violation) {
                $this->output->writeln(sprintf('<error>%s : %s</error>', $violation->getPropertyPath(), $violation->getMessage()));
            }

            return false;
        }

        return true;
    }
552616
protected function init(DOMElement $element)
    {
        $this->parseType($element);
        $this->parseId($element, false);
        $this->parseName($element, false);

        $this->parseArgs($element);
    }
457008
protected function processChild(\DOMElement $element, ContextInterface $context)
    {
        if ($element->hasAttribute('itemscope') && empty($element->getAttribute('itemprop'))) {
            $context = $this->createAndAddChild($element, $context);
        }

        return $context;
    }
569735
public function formElement(IElement $element)
    {
        if ($element instanceof Textarea) {
            return $this->formTextarea($element);
        } elseif ($element instanceof Select) {
            return $this->formSelect($element);
        } elseif ($element instanceof Submit) {
            return $this->formInput($element);
        } elseif ($element instanceof Button) {
            // todo: is it right?
            throw new InvalidArgumentException("Button element should be rendered without Helper.");
        } else {
            return $this->formInput($element);
        }
    }
639213
protected function yieldAssignmentElement(AssignmentElement $element)
    {
        foreach ($this->getOption('assignment_handlers') as $handler) {
            $iterator = $handler($element) ?: [];
            foreach ($iterator as $newElement) {
                yield $newElement;
            }
        }

        /* @var MarkupElement $markup */
        $markup = $element->getContainer();

        $arguments = [];
        foreach ($markup->getAssignmentsByName('attributes') as $attributesAssignment) {
            /* @var AssignmentElement $attributesAssignment */
            foreach ($attributesAssignment->getAttributes() as $attribute) {
                /* @var AbstractValueElement $attribute */
                $value = $attribute;
                $checked = method_exists($value, 'isChecked') && $value->isChecked();
                while (method_exists($value, 'getValue')) {
                    $value = $value->getValue();
                }
                $arguments[] = $this->formatCode($value, $checked);
            }
            $markup->removedAssignment($attributesAssignment);
        }

        $attributes = $markup->getAttributes();
        foreach ($attributes as $attribute) {
            /* @var AttributeElement $attribute */
            $arguments[] = $this->formatAttributeAsArrayItem($attribute);
        }
        $attributes->removeAll($attributes);

        foreach ($markup->getAssignments() as $assignment) {
            /* @var AssignmentElement $assignment */
            $this->throwException(
                'Unable to handle '.$assignment->getName().' assignment',
                $assignment
            );
        }

        if (count($arguments)) {
            yield $this->attributesAssignmentsFromPairs($arguments);
        }
    }
474530
public function add($element) {
		if (!in_array($element, $this->collection, true)) {
			$this->collection[$this->size()] = $element;
		}

		return $this;
	}
303688
public function addElement(AbstractElement $element)
    {
        $name = $element->getName();
        if (in_array($name, $this->uniqueList)) {
            $this->elements[$name] = $element;
        } else {
            $this->elements[] = $element;
        }

        return $this;
    }
93320
public function addAssignment(AssignmentElement $element)
    {
        $element->setContainer($this);
        $this->getAssignments()->attach($element);

        return $this;
    }
310992
public function withPrepended(Element $el): self
    {
        $obj = clone $this;
        array_unshift($obj->_elements, $el);
        return $obj;
    }
254778
public function render(ElementInterface $element)
    {
        // Set class
        $class = $element->getAttribute('class');
        if ($class) {
            $class .= ' ';
        }
        $element->setAttribute('class', $class . 'form-control');

        // Set placeholder
        $placeholder = $element->getAttribute('placeholder');
        if (!$placeholder) {
            $element->setAttribute('placeholder', $element->getLabel());
        }

        return parent::render($element);
    }
1069662
public function render(ElementInterface $element)
    {
        $escapeHtmlHelper    = $this->getEscapeHtmlHelper();
        $labelHelper         = $this->getLabelHelper();
        $elementHelper       = $this->getElementHelper();
        $elementErrorsHelper = $this->getElementErrorsHelper();

        $label           = $element->getLabel();
        $inputErrorClass = $this->getInputErrorClass();
        $elementErrors   = $elementErrorsHelper->render($element);

        // Does this element have errors ?
        if (!empty($elementErrors) && !empty($inputErrorClass)) {
            $classAttributes = ($element->hasAttribute('class') ? $element->getAttribute('class') . ' ' : '');
            $classAttributes = $classAttributes . $inputErrorClass;

            $element->setAttribute('class', $classAttributes);
        }

        $elementString = $elementHelper->render($element);

        if (isset($label) && '' !== $label) {
            // Translate the label
            if (null !== ($translator = $this->getTranslator())) {
                $label = $translator->translate(
                    $label,
                    $this->getTranslatorTextDomain()
                );
            }

            $label = $escapeHtmlHelper($label);
            $labelAttributes = $element->getLabelAttributes();

            if (empty($labelAttributes)) {
                $labelAttributes = $this->labelAttributes;
            }

            // Multicheckbox elements have to be handled differently as the HTML standard does not allow nested
            // labels. The semantic way is to group them inside a fieldset
            $type = $element->getAttribute('type');
            if ($type === 'multi_checkbox' || $type === 'radio') {
                $markup = sprintf(
                    '<fieldset><legend>%s</legend>%s</fieldset>',
                    $label,
                    $elementString
                );
            } else {
                if ($element->hasAttribute('id')) {
                    $labelOpen = $labelHelper($element);
                    $labelClose = '';
                    $label = '';
                } else {
                    $labelOpen  = $labelHelper->openTag($labelAttributes);
                    $labelClose = $labelHelper->closeTag();
                }

                if ($label !== '') {
                    $label = '<span>' . $label . '</span>';
                }

                switch ($this->labelPosition) {
                    case self::LABEL_PREPEND:
                        $markup = $labelOpen . $label . $elementString . $labelClose;
                        break;
                    case self::LABEL_APPEND:
                    default:
                        $markup = $labelOpen . $elementString . $label . $labelClose;
                        break;
                }
            }

            if ($this->renderErrors) {
                //$markup .= $elementErrors;
            }
        } else {
            if ($this->renderErrors) {
                $markup = $elementString;  //. $elementErrors;
            } else {
                $markup = $elementString;
            }
        }

        return $markup;
    }
288144
public static function preRenderWebformElement($element) {
    $webform = ($element['#webform'] instanceof WebformInterface) ? $element['#webform'] : WebformEntity::load($element['#webform']);
    if (!$webform) {
      return $element;
    }

    if ($webform->access('submission_create')) {
      $values = [];

      // Set data.
      $values['data'] = $element['#default_data'];

      // Set source entity type and id.
      if (!empty($element['#entity']) && $element['#entity'] instanceof EntityInterface) {
        $values['entity_type'] = $element['#entity']->getEntityTypeId();
        $values['entity_id'] = $element['#entity']->id();
      }
      elseif (!empty($element['#entity_type']) && !empty($element['#entity_id'])) {
        $values['entity_type'] = $element['#entity_type'];
        $values['entity_id'] = $element['#entity_id'];
      }

      if (!empty($element['#override'])) {
        $new_settings = $element['#override'];
        $webform->setSettingsOverride($new_settings);
        $values['strawberryfield:override'] = $new_settings;

      }

      // Build the webform.
      $element['webform_build'] = $webform->getSubmissionForm($values);

      // Set custom form action.
      if (!empty($element['#action'])) {
        $element['webform_build']['#action'] = $element['#action'];
      }
    }
    elseif ($webform->getSetting('form_access_denied') !== WebformInterface::ACCESS_DENIED_DEFAULT) {
      // Set access denied message.
      $element['webform_access_denied'] = static::buildAccessDenied($webform);
    }
    else {
      // Add config and webform to cache contexts.
      $config = \Drupal::configFactory()->get('webform.settings');
      $renderer = \Drupal::service('renderer');
      $renderer->addCacheableDependency($element, $config);
      $renderer->addCacheableDependency($element, $webform);
    }

    return $element;
  }
455609
public function remove(Interfaces\IElement $element)
    {
        if ($this->elements->contains($element)) {
            $this->elements->detach($element);
        }

        return $this;
    }