API

Table of Contents

The following list provides information for all necessary interfaces and classes that are used inside of this documentation. For up to date information, please check the source code.

Interfaces

interface Brotkrueml\FeedGenerator\Feed\AuthorInterface

Has to be implemented to provide an author to a feed or an item. The extension provides already an implementation (Brotkrueml\FeedGenerator\Feed\Author) which can be used. However, if you have special needs you can use this interface to implement a custom author class.

getName()
Return type

string

Returns

The name of the author.

getUri()
Return type

string

Returns

The URI of the author. Return an empty string to omit the property.

getEmail()
Return type

string

Returns

The email address of the author. Return an empty string to omit the property.

interface Brotkrueml\FeedGenerator\Feed\FeedInterface

Has to be implemented to provide a feed. It extends Brotkrueml\FeedGenerator\Feed\NodeInterface.

getDescription()
Return type

string

Returns

The description of the feed. Return an empty string to omit the property in the feed.

getLanguage()
Return type

string

Returns

The language of the feed. Return an empty string to omit the property in the feed.

Return type

string

Returns

The logo of the feed. Return an empty string to omit the property in the feed.

getItems()
Return type

ItemInterface[]

Returns

The items of the feed. Return an empty array to omit the property in the feed.

interface Brotkrueml\FeedGenerator\Feed\FeedFormatAwareInterface

This interface is used in combination with the Brotkrueml\FeedGenerator\Feed\FeedInterface to set the current feed format into a feed implementation. It can be used in combination with the Brotkrueml\FeedGenerator\Feed\StyleSheetAwareInterface to provide different XSL stylesheets for Atom and RSS feeds.

setFormat($format)

In the implementation of this method store the format in a property of your class for later usage.

Parameters
interface Brotkrueml\FeedGenerator\Feed\ItemInterface

Has to be implemented to provide an item of the feed. It extends Brotkrueml\FeedGenerator\Feed\NodeInterface. The extension provides already an implementation (Brotkrueml\FeedGenerator\Feed\Item) which can be used. However, if you have special needs you can use this interface to implement a custom item class.

getSummary()
Return type

string

Returns

The summary of the feed. Return an empty string to omit the property in the feed.

getContent()
Return type

string

Returns

The content of the feed. Return an empty string to omit the property in the feed.

Note

When the item is used for an RSS feed, the summary is not displayed, the content is used for the description tag of an item.

interface Brotkrueml\FeedGenerator\Feed\MediaInterface

Has to be implemented to provide one or more media assets (like image, video, audio) to an item. The extension provides already an implementation (Brotkrueml\FeedGenerator\Feed\Media) which can be used. However, if you have special needs you can use this interface to implement a custom media class.

getType()
Return type

string

Returns

Get the mime type of the media.

getUrl()
Return type

string

Returns

Get the URL of the media.

getLength()
Return type

int

Returns

Get the length (in bytes) of the media.

getTitle()
Return type

string

Returns

Get the title of the media. It is used only in a JSON feed.

interface Brotkrueml\FeedGenerator\Feed\NodeInterface

This interface is extended by the Brotkrueml\FeedGenerator\Feed\FeedInterface and the Brotkrueml\FeedGenerator\Feed\ItemInterface.

getLastModified()
Return type

?DateTimeInterface

Returns

The date and time of the last modification. Return null to omit the property in the feed.

getTitle()
Return type

string

Returns

The title. Return an empty string to omit the property in the feed.

getPublicId()
Return type

string

Returns

The ID. Return an empty string to omit the property in the feed.

Return type

string

Returns

The link. Return an empty string to omit the property in the feed.

interface Brotkrueml\FeedGenerator\Feed\RequestAwareInterface

This interface is used in combination with the Brotkrueml\FeedGenerator\Feed\FeedInterface to inject the request into a feed implementation.

setRequest($request)

In the implementation of this method store the request object in a property of your class for later usage.

Parameters
  • $request (Psr\Http\Message\ServerRequestInterface) -- The request object.

interface Brotkrueml\FeedGenerator\Feed\StyleSheetAwareInterface

This interface is used in combination with the Brotkrueml\FeedGenerator\Feed\FeedInterface to get an XSL stylesheet which is applied to an Atom or RSS feed.

getStyleSheet()
Return type

string

Returns

The path to an XSL stylesheet. Return an empty string to omit the adding of the stylesheet to the XML feed.

Classes

class Brotkrueml\FeedGenerator\Feed\Author

The class implements the Brotkrueml\FeedGenerator\Feed\AuthorInterface and can be used to define an author for a feed or a feed item.

__construct()
Parameters
  • $name (string) -- The name of the author.

  • $uri (string) -- The URI of the author. Used in Atom and JSON formats only.

  • $email (string) -- The email address of the author. Used in Atom format only.

getName()
Return type

string

Returns

The name of the author.

getUri()
Return type

string

Returns

The URI of the author.

getEmail()
Return type

string

Returns

The email address of the author.

class Brotkrueml\FeedGenerator\Feed\Item

The class implements the Brotkrueml\FeedGenerator\Feed\ItemInterface and can be used to define an item for a feed.

__construct()
Parameters
  • $title (string) -- The title of the item.

  • $publicId (string) -- The ID of the item.

  • $lastModified (?DateTimeInterface) -- The last modification date of the item.

  • $link (string) -- The link of the item.

  • $summary (string) -- The summary of the item.

  • $content (string) -- The content of the item.

Tip

For better readability or when omitting some of the parameters use named arguments:

$item = new Brotkrueml\FeedGenerator\Feed\Item(
   title: 'The title',
   link: 'https://example.com/the/page',
   summary: 'Some summary',
);
getTitle()
Return type

string

Returns

The title of the item.

getPublicId()
Return type

string

Returns

The ID of the item.

getLastModified()
Return type

?DateTimeInterface

Returns

The last modification date of the item.

Return type

string

Returns

The link of the item.

getSummary()
Return type

string

Returns

The summary of the item.

getContent()
Return type

string

Returns

The content of the item.

class Brotkrueml\FeedGenerator\Feed\Media

The class implements the Brotkrueml\FeedGenerator\Feed\MediaInterface and can be used to define a media asset for a feed item.

__construct()
Parameters
  • $type (string) -- The mime type of the media.

  • $url (string) -- The URL of the media.

  • $length (int) -- The length (in bytes) of the media.

  • $title (string) -- The title of the media. Use only in a JSON feed.

getType()
Return type

string

Returns

The type of the media.

getUrl()
Return type

string

Returns

The URL of the media.

getLength()
Return type

int

Returns

The length (in bytes) of the media.

getTitle()
Return type

string

Returns

The title of the media.

Enumerations

class Brotkrueml\FeedGenerator\Feed\FeedFormat

The enumeration provides the following names which describe the available feed formats:

  • ATOM

  • JSON

  • RSS

Note

Only the enumeration names are public API. Methods that may be available are not part of the backwards-compatible promise and can change at any time without prior notice!