Add element

@param Element\NamedElement $element

@throws Exception\AttachException

@return $this
160185
public function attach(Element\NamedElement $element)
    {
        if (!$this->getByName($element->getName(), false)) {
            $this->attach($element);
        } else {
            throw new Exception\AttachException();
        }

        return $this;
    }
99564
private function addElement($name, $parent = false, $ns = false)
    {
        if ($ns) {
            $el = $parent->ownerDocument->createElementNS($ns, $name);
        } else {
            $el = $parent->ownerDocument->createElement($name);
        }
        if ($parent) {
            $parent->appendChild($el);
        }

        return $el;
    }
83551
public function add($element)
    {
        if ($element instanceof TermQuery) {
            parent::add($element);
        } else {
            parent::add(
                (new TermQuery())
                    ->setValue($element)
            );
        }

        return $this;
    }
183655
public function addElement(Element $element): Element
    {
        foreach ($this->notAllowedElements as $notAllowed) {
            if ($element instanceof $notAllowed) {
                $callerName = \str_replace([__NAMESPACE__, '\\'], '', \get_called_class());
                $notAllowedName = \str_replace([__NAMESPACE__, '\\'], '', $notAllowed);
                throw new InvalidArgumentException($callerName.' cannot contain '.$notAllowedName);
            }
        }
        $this->elements[] = $element;
        return $element;
    }
368882
public function setListElement($element)
    {
        if (!is_string($element)) {
            throw new \InvalidArgumentException(
                'Breadcrumbs::setListElement() only accepts strings, but '
                . (is_object($element) ? get_class($element) : gettype($element))
                . ' given: ' . print_r($element, true)
            );
        }

        $this->listElement = $element;

        return $this;
    }
80368
public function addToOtherGroup($element)
    {
        if ($element instanceof \Zend_Form_Element) {
            if ($group = $this->getDisplayGroup(self::GROUP_OTHER)) {
                $group->addElement($element);
            } else  {
                $this->addDisplayGroup(array($element), self::GROUP_OTHER);
            }
        }
        return $this;
    }
471648
public function addElement(\Zend_Form_Element $element)
    {
        $decorators = $element->getDecorators();
        $decorator = array_shift($decorators);
        $element->setDecorators(array($decorator,
            array('Description', array('class'=>'description')),
                            'Errors',
                            array(array('data' => 'HtmlTag'), array('tag' => 'td', 'class' => 'element')),
                            array('Label'),
                            array(array('labelCell' => 'HtmlTag'), array('tag' => 'td', 'class'=>'label')),
                            array(array('row' => 'HtmlTag'), array('tag' => 'tr', 'class' => $this->_alternate))
            ));
        
        return parent::addElement($element);
    }
437721
public function addElement(Element $element)
    {
        if (!in_array($element, $this->elements, true)) {
            array_push($this->elements, $element);
        }
        return $this;
    }
868989
public function AddElement($name, $data)
    {
        $this->factory->addElement($this, $name, $data);
        return $this;
    }
1071123
public function addElement($element, $name = null, $options = null) {
        if (is_string($element)) {
            $index = isset($options['index']) ? $options['index'] : 0;
            unset($options['index']);
        } elseif ($element instanceof Zend_Form_Element) {
            $index = $element->getAttrib('index') ?: 0;
            $element->setAttrib('index', null);
        } else {
            throw new Garp_Form_Exception('Unable to resolve given element. $element must be string or Zend_Form_Element.');
        }

        if (!$subform = $this->getSubForm($index)) {
            $subform = $this->_createSubFormAtIndex($index);
            $this->addSubForm($subform);
        }
        $subform->addElement($element, $name, $options);
    }
717501
public function appendChildNode(\SimpleXMLElement $element)
    {
        $target  = dom_import_simplexml($this);
        $insert = $target->ownerDocument->importNode(dom_import_simplexml($element), true);
        $target->appendChild($insert);
    }
374433
public function appendToHead($element)
    {
        // Check if the element is valid
        if (empty($element)) {
            throw new InvalidArgumentException('The element provided is empty.');
        }

        // Append element to head
        $this->getHead()->append($element);

        return $this;
    }
1098320
public function setDOM(DOMElement $element)
    {
        $this->_element = $this->_element->ownerDocument->importNode($element, true);
    }
1338534
public function prependChild(Element $element)
	{
		$this->beforeInsert($element);
		
		array_unshift($this->children, $element);
		
		$this->afterInsert();
		
		return $this;
	}
1231186
public function addElement(FormElement $element) {

		if(!empty($this->elements[$element->getName()])) {
			
			throw new HtmlFormException(sprintf("Element '%s' already assigned.", $element->getName()));
			
		}

		$this->elements[$element->getName()] = $element;
		$element->setForm($this);

		return $this;

	}
392789
public function addElement($col, $name = null) {
		// Width
		if (is_int($col)) {
			$col = new TableCol([self::ATTR_WIDTH => $col . '%']);
		}
		// Attributes or class
		else if (is_array($col) || is_string($col)) {
			$col = new TableCol($col);
		}
		// Instance
		else if (! $col instanceof TableCol) {
			throw new Exception('Element must be an instance of the TableCol or a array or a string');
		}
		
		return parent::addElement($col, $name);
	}
565964
public function add(Component $element)
    {
        $this->elements[] = $element;
        $this->indentations[] = $this->currentIndentation;

        if ($element instanceof LabeledParagraph) {
            $this->alignment->add($element, $this->currentIndentation);
            $element->setAlignment($this->alignment);
        }

        return $this;
    }