FeedWriter\Item::getElements PHP Méthode

getElements() public méthode

Return the collection of elements in this feed item
public getElements ( ) : array
Résultat array All elements of this item.
    public function getElements()
    {
        // ATOM feeds have some specific requirements...
        if ($this->version == Feed::ATOM) {
            // Add an 'id' element, if it was not added by calling the setLink method.
            // Use the value of the title element as key, since no link element was specified.
            if (!array_key_exists('id', $this->elements)) {
                $this->setId(Feed::uuid($this->elements['title']['content'], 'urn:uuid:'));
            }
            // Either a 'link' or 'content' element is needed.
            if (!array_key_exists('content', $this->elements) && !array_key_exists('link', $this->elements)) {
                throw new InvalidOperationException('ATOM feed entries need a link or a content element. Call the setLink or setContent method.');
            }
        } else {
            if ($this->version == Feed::RSS1) {
                if (!array_key_exists('title', $this->elements)) {
                    throw new InvalidOperationException('RSS1 feed entries need a title element. Call the setTitle method.');
                }
                if (!array_key_exists('link', $this->elements)) {
                    throw new InvalidOperationException('RSS1 feed entries need a link element. Call the setLink method.');
                }
            }
        }
        return $this->elements;
    }