PHP Класс ActiveResource\ActiveResource

Intended to work with RoR-based REST servers, which all share similar API patterns. Usage: 'Joe Cocker', 'title' => 'A Little Help From My Friends')); $song->save (); fetch and update an item $song->find (44)->set ('title', 'The River')->save (); line by line $song->find (44); $song->title = 'The River'; $song->save (); get all songs $songs = $song->find ('all'); delete a song $song->find (44); $song->destroy (); custom method $songs = $song->get ('by_year', array ('year' => 1999)); ?>
Автор: John Luxford ([email protected])
Показать файл Открыть проект

Открытые свойства

Свойство Тип Описание
$element_name The remote collection, e.g., person or thing
$element_name_plural Pleural form of the element name, e.g., people or things
$errno The error number if an error occurred.
$error An error message if an error occurred.
$extra_params Add any extra params to the end of the url eg: API key
$password HTTP Basic Authentication password
$pleural_corrections Corrections to improper pleuralizations.
$request_body The request that was sent to the server.
$request_format The format requests should use to send data (url or xml).
$request_headers The request headers that was sent to the server.
$request_method The request method sent to the server.
$request_uri The complete URL that the request was sent to.
$response_body The response body sent from the server.
$response_code The response code returned from the server.
$response_headers The raw response headers sent from the server.
$site The REST site address, e.g., http://user:pass@domain:port/
$user HTTP Basic Authentication user

Открытые методы

Метод Описание
__construct ( $data = [] ) Constructor method.
__get ( $k ) Getter for internal object data.
__set ( $k, $v ) Setter for internal object data.
_build_xml ( $k, $v ) Simple recursive function to build an XML response.
_fetch ( $url, $method, $params ) Fetch the specified request via cURL.
_send_and_receive ( $url, $method, $data = [], $start_tag = false ) Build the request, call _fetch() and parse the results.
_unicode_ord ( string &$c, integer &$i ) : integer Returns the unicode value of the string
_xml_entities ( string $s, boolean $hex = true ) : string Makes the specified string XML-safe
destroy ( ) Deletes a record via:
find ( $id = false, $options = [] ) Finds a record or records via:
get ( $method, $options = [] ) Gets a specified custom method on the current object via:
pleuralize ( $word ) For backwards-compatibility.
pluralize ( $word ) Pluralize the element name.
post ( $method, $options = [], $start_tag = false ) Posts to a specified custom method on the current object via:
put ( $method, $options = [], $options_as_xml = false, $start_tag = false ) Puts to a specified custom method on the current object via:
save ( ) Saves a new record or updates an existing one via:
set ( $k, $v = false ) Quick setter for chaining methods.

Описание методов

__construct() публичный Метод

Constructor method.
public __construct ( $data = [] )

__get() публичный Метод

Getter for internal object data.
public __get ( $k )

__set() публичный Метод

Setter for internal object data.
public __set ( $k, $v )

_build_xml() публичный Метод

Simple recursive function to build an XML response.
public _build_xml ( $k, $v )

_fetch() публичный Метод

Fetch the specified request via cURL.
public _fetch ( $url, $method, $params )

_send_and_receive() публичный Метод

Build the request, call _fetch() and parse the results.
public _send_and_receive ( $url, $method, $data = [], $start_tag = false )

_unicode_ord() публичный Метод

Returns the unicode value of the string
См. также: http://www.php.net/manual/en/function.ord.php#78032
Автор: kerry at shetline dot com
Автор: Dom Hastings - modified to suit my needs
public _unicode_ord ( string &$c, integer &$i ) : integer
$c string The source string
$i integer The index to get the char from (passed by reference for use in a loop)
Результат integer The value of the char at $c[$i]

_xml_entities() публичный Метод

Makes the specified string XML-safe
См. также: http://www.w3.org/TR/REC-xml/#sec-predefined-ent
Автор: Dom Hastings
public _xml_entities ( string $s, boolean $hex = true ) : string
$s string
$hex boolean Whether or not to make hexadecimal entities (as opposed to decimal)
Результат string The XML-safe result

destroy() публичный Метод

DELETE /collection/id.xml
public destroy ( )

find() публичный Метод

GET /collection/id.xml GET /collection.xml
public find ( $id = false, $options = [] )

get() публичный Метод

GET /collection/id/method.xml GET /collection/id/method.xml?attr=value
public get ( $method, $options = [] )

pleuralize() публичный Метод

For backwards-compatibility.
public pleuralize ( $word )

pluralize() публичный Метод

Pluralize the element name.
public pluralize ( $word )

post() публичный Метод

POST /collection/id/method.xml
public post ( $method, $options = [], $start_tag = false )

put() публичный Метод

PUT /collection/id/method.xml
public put ( $method, $options = [], $options_as_xml = false, $start_tag = false )

save() публичный Метод

POST /collection.xml PUT /collection/id.xml
public save ( )

set() публичный Метод

Quick setter for chaining methods.
public set ( $k, $v = false )

Описание свойств

$element_name публичное свойство

The remote collection, e.g., person or thing
public $element_name

$element_name_plural публичное свойство

Pleural form of the element name, e.g., people or things
public $element_name_plural

$errno публичное свойство

The error number if an error occurred.
public $errno

$error публичное свойство

An error message if an error occurred.
public $error

$extra_params публичное свойство

Add any extra params to the end of the url eg: API key
public $extra_params

$password публичное свойство

HTTP Basic Authentication password
public $password

$pleural_corrections публичное свойство

Corrections to improper pleuralizations.
public $pleural_corrections

$request_body публичное свойство

The request that was sent to the server.
public $request_body

$request_format публичное свойство

The format requests should use to send data (url or xml).
public $request_format

$request_headers публичное свойство

The request headers that was sent to the server.
public $request_headers

$request_method публичное свойство

The request method sent to the server.
public $request_method

$request_uri публичное свойство

The complete URL that the request was sent to.
public $request_uri

$response_body публичное свойство

The response body sent from the server.
public $response_body

$response_code публичное свойство

The response code returned from the server.
public $response_code

$response_headers публичное свойство

The raw response headers sent from the server.
public $response_headers

$site публичное свойство

The REST site address, e.g., http://user:pass@domain:port/
public $site

$user публичное свойство

HTTP Basic Authentication user
public $user