PHP Class 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)); ?>
Author: John Luxford ([email protected])
Afficher le fichier Open project: jbroadway/phpactiveresource

Méthodes publiques

Свойство Type Description
$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

Méthodes publiques

Méthode Description
__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.

Method Details

__construct() public méthode

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

__get() public méthode

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

__set() public méthode

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

_build_xml() public méthode

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

_fetch() public méthode

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

_send_and_receive() public méthode

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

_unicode_ord() public méthode

Returns the unicode value of the string
See also: http://www.php.net/manual/en/function.ord.php#78032
Author: kerry at shetline dot com
Author: 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)
Résultat integer The value of the char at $c[$i]

_xml_entities() public méthode

Makes the specified string XML-safe
See also: http://www.w3.org/TR/REC-xml/#sec-predefined-ent
Author: 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)
Résultat string The XML-safe result

destroy() public méthode

DELETE /collection/id.xml
public destroy ( )

find() public méthode

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

get() public méthode

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

pleuralize() public méthode

For backwards-compatibility.
public pleuralize ( $word )

pluralize() public méthode

Pluralize the element name.
public pluralize ( $word )

post() public méthode

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

put() public méthode

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

save() public méthode

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

set() public méthode

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

Property Details

$element_name public_oe property

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

$element_name_plural public_oe property

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

$errno public_oe property

The error number if an error occurred.
public $errno

$error public_oe property

An error message if an error occurred.
public $error

$extra_params public_oe property

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

$password public_oe property

HTTP Basic Authentication password
public $password

$pleural_corrections public_oe property

Corrections to improper pleuralizations.
public $pleural_corrections

$request_body public_oe property

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

$request_format public_oe property

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

$request_headers public_oe property

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

$request_method public_oe property

The request method sent to the server.
public $request_method

$request_uri public_oe property

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

$response_body public_oe property

The response body sent from the server.
public $response_body

$response_code public_oe property

The response code returned from the server.
public $response_code

$response_headers public_oe property

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

$site public_oe property

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

$user public_oe property

HTTP Basic Authentication user
public $user