mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-08-05 16:17:28 +02:00
[FormatInterface] Add functions from FormatAbstract
@@ -1,21 +1,18 @@
|
||||
The `FormatInterface`interface defines functions that need to be implemented by all formats:
|
||||
|
||||
* [setItems](#the-setitems-function)
|
||||
* [display](#the-display-function)
|
||||
* [stringify](#the-stringify-function)
|
||||
* [setItems](#the-setitems-function)
|
||||
* [getItems](#the-getitems-function)
|
||||
* [setCharset](#the-setcharset-function)
|
||||
* [getCharset](#the-getcharset-function)
|
||||
* [setExtraInfos](#the-setextrainfos-function)
|
||||
* [getExtraInfos](#the-getextrainfos-function)
|
||||
|
||||
Find a [template](#template) at the end of this file
|
||||
|
||||
#Functions
|
||||
|
||||
##The `setItems` function
|
||||
|
||||
The `setItems` function receives an array of items generated by the bridge and must return the object instance. Each item represents an entry in the feed. For more information refer to [BridgeAbstract](BridgeAbstract#items).
|
||||
|
||||
```PHP
|
||||
setItems(array $items): self
|
||||
```
|
||||
|
||||
##The `display` function
|
||||
|
||||
The `display` function shows the contents to the user and must return the object instance.
|
||||
@@ -32,6 +29,61 @@ The `stringify` function returns the items received by [`setItems`](#the-setitem
|
||||
stringify(): string
|
||||
```
|
||||
|
||||
##The `setItems` function
|
||||
|
||||
The `setItems` function receives an array of items generated by the bridge and must return the object instance. Each item represents an entry in the feed. For more information refer to [BridgeAbstract](BridgeAbstract#items).
|
||||
|
||||
```PHP
|
||||
setItems(array $items): self
|
||||
```
|
||||
|
||||
##The `getItems` function
|
||||
|
||||
The `getItems` function returns the items previously set by the [`setItems`](FormatInterface#the-setitems-function) function. If no items where set previously this function returns an error.
|
||||
|
||||
```PHP
|
||||
getItems(): array
|
||||
```
|
||||
|
||||
##The `setCharset` function
|
||||
|
||||
The `setCharset` function receives the character set value as string and returns the object instance.
|
||||
|
||||
```PHP
|
||||
setCharset(string): self
|
||||
```
|
||||
|
||||
##The `getCharset` function
|
||||
|
||||
The `getCharset` function returns the character set value.
|
||||
|
||||
```PHP
|
||||
getCharset(): string
|
||||
```
|
||||
|
||||
##The `setExtraInfos` function
|
||||
|
||||
The `setExtraInfos` function receives an array of elements with additional information to generate format outputs and must return the object instance.
|
||||
|
||||
```PHP
|
||||
setExtraInfos(array $infos): self
|
||||
```
|
||||
|
||||
Currently supported information are:
|
||||
|
||||
Name | Description
|
||||
-----|------------
|
||||
`name` | Defines the name as generated by the bridge
|
||||
`uri` | Defines the URI of the feed as generated by the bridge
|
||||
|
||||
##The `getExtraInfos` function
|
||||
|
||||
The `getExtraInfos` function returns the information previously set via the [`setExtraInfos`](#the-setextrainfos-function) function.
|
||||
|
||||
```PHP
|
||||
getExtraInfos(): array
|
||||
```
|
||||
|
||||
#Template
|
||||
|
||||
This is a bare minimum template for a format:
|
||||
@@ -39,14 +91,9 @@ This is a bare minimum template for a format:
|
||||
```PHP
|
||||
<?php
|
||||
class MyTypeFormat implements FormatInterface {
|
||||
public function setItems(array $items){
|
||||
// Implement your code here!
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function stringify(){
|
||||
// Implement your code here
|
||||
return '';
|
||||
return ''; // Return items as string
|
||||
}
|
||||
|
||||
public function display(){
|
||||
@@ -54,6 +101,36 @@ class MyTypeFormat implements FormatInterface {
|
||||
echo $this->stringify();
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setItems(array $items){
|
||||
// Implement your code here!
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getItems(){
|
||||
// Implement your code here!
|
||||
return array(); // Return original items
|
||||
}
|
||||
|
||||
public function setCharset($charset){
|
||||
// Implement your code here!
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCharset(){
|
||||
// Implement your code here!
|
||||
return ''; // Return the charset!
|
||||
}
|
||||
|
||||
public function setExtraInfos(array $infos){
|
||||
// Implement your code here!
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getExtraInfos(){
|
||||
// Implement your code here!
|
||||
return array(); // Return the original infos!
|
||||
}
|
||||
}
|
||||
// Imaginary empty line!
|
||||
```
|
Reference in New Issue
Block a user