PHP Класс FeedWriter\Item

Item class - Used as feed element in Feed class
Автор: Anis uddin Ahmad ([email protected])
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
__construct ( string $version = Feed::RSS2 ) Constructor
addElement ( string $elementName, string $content, array $attributes = null, boolean $overwrite = FALSE, boolean $allowMultiple = FALSE ) : self Add an element to elements array
addElementArray ( array $elementArray ) : self Set multiple feed elements from an array.
addEnclosure ( string $url, integer $length, string $type, boolean $multiple = TRUE ) : self Attach a external media to the feed item.
getElements ( ) : array Return the collection of elements in this feed item
getVersion ( ) : string Return the type of this feed item
setAuthor ( string $author, string | null $email = null, string | null $uri = null ) : self Set the 'author' element of feed item.
setContent ( string $content ) : self Set the 'content' element of the feed item For ATOM feeds only
setDate ( DateTim\DateTime | integer | string $date ) : self Set the 'date' element of the feed item.
setDescription ( string $description ) : self Set the 'description' element of feed item
setId ( string $id, boolean $permaLink = false ) : self Set the unique identifier of the feed item
setLink ( string $link ) : self Set the 'link' element of feed item
setTitle ( string $title ) : self Set the 'title' element of feed item

Приватные методы

Метод Описание
cpt ( ) : integer Return an unique number

Описание методов

__construct() публичный Метод

Constructor
public __construct ( string $version = Feed::RSS2 )
$version string constant (RSS1/RSS2/ATOM) RSS2 is default.

addElement() публичный Метод

Add an element to elements array
public addElement ( string $elementName, string $content, array $attributes = null, boolean $overwrite = FALSE, boolean $allowMultiple = FALSE ) : self
$elementName string The tag name of an element
$content string The content of tag
$attributes array Attributes (if any) in 'attrName' => 'attrValue' format
$overwrite boolean Specifies if an already existing element is overwritten.
$allowMultiple boolean Specifies if multiple elements of the same name are allowed.
Результат self

addElementArray() публичный Метод

Elements which have attributes cannot be added by this method
public addElementArray ( array $elementArray ) : self
$elementArray array
Результат self

addEnclosure() публичный Метод

Not supported in RSS 1.0 feeds. See RFC 4288 for syntactical correct MIME types. Note that you should avoid the use of more than one enclosure in one item, since some RSS aggregators don't support it.
public addEnclosure ( string $url, integer $length, string $type, boolean $multiple = TRUE ) : self
$url string The URL of the media.
$length integer The length of the media.
$type string The MIME type attribute of the media.
$multiple boolean Specifies if multiple enclosures are allowed
Результат self

getElements() публичный Метод

Return the collection of elements in this feed item
public getElements ( ) : array
Результат array All elements of this item.

getVersion() публичный Метод

Return the type of this feed item
public getVersion ( ) : string
Результат string The feed type, as defined in Feed.php

setAuthor() публичный Метод

Not supported in RSS 1.0 feeds.
public setAuthor ( string $author, string | null $email = null, string | null $uri = null ) : self
$author string The author of this item
$email string | null Optional email address of the author
$uri string | null Optional URI related to the author
Результат self

setContent() публичный Метод

Set the 'content' element of the feed item For ATOM feeds only
public setContent ( string $content ) : self
$content string Content for the item (i.e., the body of a blog post).
Результат self

setDate() публичный Метод

The value of the date parameter can be either an instance of the DateTime class, an integer containing a UNIX timestamp or a string which is parseable by PHP's 'strtotime' function.
public setDate ( DateTim\DateTime | integer | string $date ) : self
$date DateTim\DateTime | integer | string Date which should be used.
Результат self

setDescription() публичный Метод

Set the 'description' element of feed item
public setDescription ( string $description ) : self
$description string The content of the 'description' or 'summary' element
Результат self

setId() публичный Метод

On ATOM feeds, the identifier must begin with an valid URI scheme.
public setId ( string $id, boolean $permaLink = false ) : self
$id string The unique identifier of this item
$permaLink boolean The value of the 'isPermaLink' attribute in RSS 2 feeds.
Результат self

setTitle() публичный Метод

Set the 'title' element of feed item
public setTitle ( string $title ) : self
$title string The content of 'title' element
Результат self