PHP Class Contao\Feed

The class provides an interface to create RSS or Atom feeds. You can add the feed item objects and the class will generate the XML markup. Usage: $feed = new Feed('news'); $feed->title = 'News feed'; $item = new FeedItem(); $item->title = 'Latest news'; $item->author = 'Leo Feyer'; $feed->addItem($item); echo $feed->generateRss();
Inheritance: extends System
Exibir arquivo Open project: contao/core-bundle

Protected Properties

Property Type Description
$arrData array Data
$arrItems array Items
$strName string Feed name

Public Methods

Method Description
__construct ( string $strName ) Store the feed name (without file extension)
__get ( string $strKey ) : mixed | null Return an object property
__isset ( string $strKey ) : boolean Check whether a property is set
__set ( string $strKey, mixed $varValue ) Set an object property
addItem ( FeedItem $objItem ) Add an item
generateAtom ( ) : string Generate an Atom feed and return it as XML string
generateRss ( ) : string Generate an RSS 2.0 feed and return it as XML string

Protected Methods

Method Description
adjustPublicationDate ( ) Adjust the publication date

Method Details

__construct() public method

Store the feed name (without file extension)
public __construct ( string $strName )
$strName string The feed name

__get() public method

Return an object property
public __get ( string $strKey ) : mixed | null
$strKey string The property name
return mixed | null The property value

__isset() public method

Check whether a property is set
public __isset ( string $strKey ) : boolean
$strKey string The property name
return boolean True if the property is set

__set() public method

Set an object property
public __set ( string $strKey, mixed $varValue )
$strKey string The property name
$varValue mixed The property value

addItem() public method

Add an item
public addItem ( FeedItem $objItem )
$objItem FeedItem The feed item object

adjustPublicationDate() protected method

Adjust the publication date
protected adjustPublicationDate ( )

generateAtom() public method

Generate an Atom feed and return it as XML string
public generateAtom ( ) : string
return string The Atom feed markup

generateRss() public method

Generate an RSS 2.0 feed and return it as XML string
public generateRss ( ) : string
return string The RSS feed markup

Property Details

$arrData protected_oe property

Data
protected array $arrData
return array

$arrItems protected_oe property

Items
protected array $arrItems
return array

$strName protected_oe property

Feed name
protected string $strName
return string