mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-07-13 15:34:44 +02:00
[FormatInterface] Add page
parent
d728112999
commit
0aa514741e
1 changed files with 59 additions and 0 deletions
59
FormatInterface.md
Normal file
59
FormatInterface.md
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
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)
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
```PHP
|
||||||
|
display(): self
|
||||||
|
```
|
||||||
|
|
||||||
|
##The `stringify` function
|
||||||
|
|
||||||
|
The `stringify` function returns the items received by [`setItems`](#the-setitem-function) as string.
|
||||||
|
|
||||||
|
```PHP
|
||||||
|
stringify(): string
|
||||||
|
```
|
||||||
|
|
||||||
|
#Template
|
||||||
|
|
||||||
|
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 '';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function display(){
|
||||||
|
// Implement your code here
|
||||||
|
echo $this->stringify();
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Imaginary empty line!
|
||||||
|
```
|
Loading…
Add table
Add a link
Reference in a new issue