1
0
mirror of https://github.com/RSS-Bridge/rss-bridge.git synced 2025-08-04 07:37:27 +02:00

Updated BridgeAbstract (markdown)

pmaziere
2016-10-06 22:07:35 +02:00
parent 09143283fe
commit 5ad98713fe

@@ -191,11 +191,10 @@ This function returns the URI to the destination site of the bridge. It will be
} }
``` ```
# Bridge Abstract functions # Helper functions
All bridges extend from `BridgeAbstract` and therefore are able to make use of functions defined in `BridgeAbstract`. Helper functions are independent function that help you to manage specific events in your bridges.
It is considered good practice to use them rather than implementing equivalent features directly in your bridges.
Following functions should be used for good practice and will support you with your bridge :
* [`returnError`](#the-returnerror-function) * [`returnError`](#the-returnerror-function)
* [`returnClientError`](#the-returnclienterror-function) * [`returnClientError`](#the-returnclienterror-function)
@@ -210,7 +209,7 @@ Following functions should be used for good practice and will support you with y
This function aborts execution of the current bridge and returns the given error message with the provided error number : This function aborts execution of the current bridge and returns the given error message with the provided error number :
```PHP ```PHP
$this->returnError('Your error message', 404) $returnError('Your error message', 404)
``` ```
Check the [list of error codes](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes) for applicable error numbers. Check the [list of error codes](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes) for applicable error numbers.
@@ -220,7 +219,7 @@ Check the [list of error codes](https://en.wikipedia.org/wiki/List_of_HTTP_statu
This function aborts execution of the current bridge and returns the given error message with error code **400**: This function aborts execution of the current bridge and returns the given error message with error code **400**:
```PHP ```PHP
$this->returnClientError('Your error message') returnClientError('Your error message')
``` ```
Use this function when the user provided invalid parameter or a required parameter is missing. Use this function when the user provided invalid parameter or a required parameter is missing.
@@ -230,17 +229,17 @@ Use this function when the user provided invalid parameter or a required paramet
This function aborts execution of the current bridge and returns the given error message with error code **500**: This function aborts execution of the current bridge and returns the given error message with error code **500**:
```PHP ```PHP
$this->returnServerError('Your error message') returnServerError('Your error message')
``` ```
Use this function when a problem occurs that has nothing to do with the parameters provided by the user. (like: Host service gone missing, empty data received, etc...) Use this function when a problem occurs that has nothing to do with the parameters provided by the user. (like: Host service gone missing, empty data received, etc...)
## The `getSimpleHTMLDOM` function ## The `getSimpleHTMLDOM` function
This function is a wrapper around the [simple_html_dom](http://simplehtmldom.sourceforge.net/) [file_get_html](http://simplehtmldom.sourceforge.net/manual_api.htm#api) function in order to provide context by design. It is considered good practice to use this function. This function is a wrapper around the [simple_html_dom](http://simplehtmldom.sourceforge.net/) [file_get_html](http://simplehtmldom.sourceforge.net/manual_api.htm#api) function in order to provide context by design.
```PHP ```PHP
$html = $this->getSimpleHTMLDOM('your URI'); $html = getSimpleHTMLDOM('your URI');
``` ```
## The `getSimpleHTMLDOMCached` function ## The `getSimpleHTMLDOMCached` function
@@ -248,7 +247,7 @@ $html = $this->getSimpleHTMLDOM('your URI');
This function does the same as the [`getSimpleHTMLDOM`](#the-getsimplehtmldom-function) function, except that the content received for the given URI is stored in a cache and loaded from cache on the next request if the specified cache duration was not reached. Use this function for data that is very unlikely to change between consecutive requests to **RSS-Bridge**. This function allows to specify the cache duration with the second parameter (default is 24 hours / 86400 seconds). This function does the same as the [`getSimpleHTMLDOM`](#the-getsimplehtmldom-function) function, except that the content received for the given URI is stored in a cache and loaded from cache on the next request if the specified cache duration was not reached. Use this function for data that is very unlikely to change between consecutive requests to **RSS-Bridge**. This function allows to specify the cache duration with the second parameter (default is 24 hours / 86400 seconds).
```PHP ```PHP
$html = $this->getSimpleHTMLDOMCached('your URI', 86400); // Duration 24h $html = getSimpleHTMLDOMCached('your URI', 86400); // Duration 24h
``` ```
**Notice:** Due to the current implementation a value greater than 86400 seconds (24 hours) will not work as the cache is purged every 24 hours automatically. **Notice:** Due to the current implementation a value greater than 86400 seconds (24 hours) will not work as the cache is purged every 24 hours automatically.