src/Elements/BaseElement.php
public function addContentElement(ApiElement $element)
    {
        $newContent = [];
        $rawElements = [];
        $content = $this->getContent();

        if ($this->hasCopy()) {
            $newContent[] = array_shift($content);
        }

        foreach ($content as $resourceGroup) {
            if (!is_array($resourceGroup)) {
                $newContent[] = array_shift($content);
            } else {
                $rawElements[] = $resourceGroup;
            }
        }

        array_shift($rawElements);
        $newContent[] = $element;

        $this->content = array_merge($newContent, $rawElements);
    }
public function addContentElement(ApiElement $element)
    {
        $newContent = [];
        $rawElements = [];
        $content = $this->getContent();

        if ($this->hasCopy()) {
            $newContent[] = array_shift($content);
        }

        foreach ($content as $resourceGroup) {
            if (!is_array($resourceGroup)) {
                $newContent[] = array_shift($content);
            } else {
                $rawElements[] = $resourceGroup;
            }
        }

        array_shift($rawElements);
        $newContent[] = $element;

        $this->content = array_merge($newContent, $rawElements);
    }
public function addContentElement ( ApiElement $ element ) { $ newContent = [ ] ; $ rawElements = [ ] ; $ content = $ this -> getContent ( ) ; if ( $ this -> hasCopy ( ) ) { $ newContent [ ] = array_shift ( $ content ) ; } foreach ( $ content as $ resourceGroup ) { if ( ! is_array ( $ resourceGroup ) ) { $ newContent [ ] = array_shift ( $ content ) ; } else { $ rawElements [ ] = $ resourceGroup ; } } array_shift ( $ rawElements ) ; $ newContent [ ] = $ element ; $ this -> content = array_merge ( $ newContent , $ rawElements ) ; }
Add content element to the current content

This method has to be used sequentially while querying the recursive
element tree. It will replace the raw content element one by one, top to bottom.

Example:

- copy element
- raw array element (1)
- raw array element (2)

Calling `addContentElement` with a resource element:

- copy element
- resource element
- raw array element (2)

As you can see `raw array element (1)` was replaced with `resource element`
So *you* need to make sure that *you* turned the raw array element into the resource element.

@param ApiElement $element
Add content element to the current content