From b59915f23be10188fa5af9b7d1977c3606a1f67d Mon Sep 17 00:00:00 2001 From: logmanoriginal Date: Sat, 6 Aug 2016 18:21:43 +0200 Subject: [PATCH] [lib/Bridge] Define default behavior for getName() and getURI() Bridges no longer require implementation for getName() and getURI() as they are now implemented with default behavior in BridgeAbstract. This was previously implemented only for RSSExpander and is now part of BridgeAbstract (automatically inherited). Documentation is updated accordingly. --- CREATE_BRIDGE.md | 24 ++++++++++-------------- lib/Bridge.php | 23 ++++++++++++++--------- 2 files changed, 24 insertions(+), 23 deletions(-) diff --git a/CREATE_BRIDGE.md b/CREATE_BRIDGE.md index 707c7a3..420248b 100644 --- a/CREATE_BRIDGE.md +++ b/CREATE_BRIDGE.md @@ -9,8 +9,8 @@ Read the following chapters an make sure to read the [Guidelines](#guidelines)! A rss bridge must extend the `BridgeAbstract` class and implement the following functions : -* [`loadMetadatas`](#the-loadmetadatas-function) -* [`collectData`](#the-collectdata-function) +* [`loadMetadatas`](#the-loadmetadatas-function) (**required**) +* [`collectData`](#the-collectdata-function) (**required**) * [`getName`](#the-getname-function) * [`getURI`](#the-geturi-function) * [`getCacheDuration`](#the-getcacheduration-function) @@ -149,9 +149,11 @@ Parameter | ATOM | HTML | (M)RSS This function returns the name of the bridge as it will be displayed on the main page of rss-bridge or on top of the feed output (HTML, ATOM, etc...). +**Notice:** rss-bridge will by default return `$this->name` which is defined in the [`loadMetadatas`](#the-loadmetadatas-function) function, so you only have to implement this function if you require different behavior! + ```PHP public function getName(){ - return ''; // Insert your bridge name here! + return $this->name; } ``` @@ -159,9 +161,11 @@ This function returns the name of the bridge as it will be displayed on the main This function returns the URI to the destination site of the bridge. It will be used on the main page of rss-bridge when clicking your bridge name. +**Notice:** rss-bridge will by default return `$this->uri` which is defined in the [`loadMetadatas`](#the-loadmetadatas-function) function, so you only have to implement this function if you require different behavior! + ```PHP public function getURI(){ - return ''; // Insert your URI here! + return $this-uri; } ``` @@ -223,8 +227,8 @@ This is the minimum template for a new bridge: class MySiteBridge extends BridgeAbstract{ public function loadMetadatas(){ $this->maintainer = 'No maintainer'; - $this->name = $this->getName(); - $this->uri = $this->getURI(); + $this->name = 'Unnamed bridge'; + $this->uri = ''; $this->description = 'No description provided'; $this->parameters = array(); } @@ -232,14 +236,6 @@ class MySiteBridge extends BridgeAbstract{ public function collectData(array $params){ // Implement your bridge here! } - - public function getName(){ - return ''; // Insert your bridge name here! - } - - public function getURI(){ - return ''; // Insert your URI here! - } } ``` diff --git a/lib/Bridge.php b/lib/Bridge.php index de9d022..4de1b4b 100644 --- a/lib/Bridge.php +++ b/lib/Bridge.php @@ -74,6 +74,20 @@ abstract class BridgeAbstract implements BridgeInterface{ } } + /** + * Define default bridge name + */ + public function getName(){ + return $this->name; + } + + /** + * Define default bridge URI + */ + public function getURI(){ + return $this->uri; + } + /** * Define default duraction for cache */ @@ -365,15 +379,6 @@ abstract class RssExpander extends HttpCachingBridgeAbstract{ */ abstract protected function parseRSSItem($item); - - public function getName(){ - return $this->name; - } - - public function getURI(){ - return $this->uri; - } - public function getDescription() { return $this->description; }