Gdata/App.php

Show: PublicProtectedPrivateinherited
Table of Contents
Zend Framework
LICENSE This source file is subject to the new BSD license that is bundled with this package in the file LICENSE.txt. It is also available through the world-wide-web at this URL: http://framework.zend.com/license/new-bsd If you did not receive a copy of the license and are unable to obtain it through the world-wide-web, please send an email to [email protected] so we can send you a copy immediately.
Category
Zend  
Copyright
Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)  
License
New BSD License  
Package
Zend_Gdata  
Subpackage
App  
Version
$Id$  

\Zend_Gdata_App

Package: Zend_Gdata\App
Provides Atom Publishing Protocol (APP) functionality. This class and all other components of Zend_Gdata_App are designed to work independently from other Zend_Gdata components in order to interact with generic APP services.
Children
\Zend_Gdata
Category
Zend  
Copyright
Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)  
License
New BSD License  

Constants

>VConstant  DEFAULT_MAJOR_PROTOCOL_VERSION = 1
Default major protocol version.
See
 
>VConstant  DEFAULT_MINOR_PROTOCOL_VERSION = null
Default minor protocol version.
See
 

Properties

>VPropertyprotectedstring $_defaultPostUri = null
Default URI to which to POST.
Default valuenullDetails
Type
string
>VPropertyprotectedboolean $_gzipEnabled = false
static
Enable gzipped responses?
Default valuefalseDetails
Type
boolean
>VPropertyprotected\Zend_Http_Client $_httpClient
Client object used to communicate
>VPropertyprotectedboolean $_httpMethodOverride = false
static
Override HTTP PUT and DELETE request methods?
Default valuefalseDetails
Type
boolean
>VPropertyprotected$_majorProtocolVersion
Indicates the major protocol version that should be used.
At present, recognized values are either 1 or 2. However, any integer value >= 1 is considered valid. Under most circumtances, this will be automatically set by Zend_Gdata_App subclasses.
Details
Type
n/a
See
 
See
 
>VPropertyprotectedint $_maxRedirects = 5
static
Maximum number of redirects to follow during HTTP operations
Default value5Details
Type
int
>VPropertyprotected$_minorProtocolVersion
Indicates the minor protocol version that should be used. Can be set to either an integer >= 0, or NULL if no minor version should be sent to the server.
At present, this field is not used by any Google services, but may be used in the future. Under most circumtances, this will be automatically set by Zend_Gdata_App subclasses.
Details
Type
n/a
See
 
See
 
>VPropertyprotectedarray $_registeredPackages = array('Zend_Gdata_App_Extension', 'Zend_Gdata_App')
Packages to search for classes when using magic __call method, in order.
Default valuearray('Zend_Gdata_App_Extension', 'Zend_Gdata_App')Details
Type
array
>VPropertyprotected\Zend_Http_Client $_staticHttpClient = null
static
Client object used to communicate in static context
Default valuenullDetails
Type
\Zend_Http_Client
>VPropertyprotectedboolean $_useObjectMapping = true
Whether we want to use XML to object mapping when fetching data.
Default valuetrueDetails
Type
boolean
>VPropertyprotectedboolean $_verboseExceptionMessages = true
static
Use verbose exception messages. In the case of HTTP errors, use the body of the HTTP response in the exception message.
Default valuetrueDetails
Type
boolean

Methods

methodpublic__call(string $method, array $args) : void

Provides a magic factory method to instantiate new objects with shorter syntax than would otherwise be required by the Zend Framework naming conventions. For instance, to construct a new Zend_Gdata_Calendar_Extension_Color, a developer simply needs to do $gCal->newColor(). For this magic constructor, packages are searched in the same order as which they appear in the $_registeredPackages array

Parameters
NameTypeDescription
$methodstring

The method name being called

$argsarray

The arguments passed to the call

Throws
ExceptionDescription
\Zend_Gdata_App_Exception
methodpublic__construct(\Zend_Http_Client $client = null, string $applicationId = 'MyCompany-MyApp-1.0') : void

Create Gdata object

Parameters
NameTypeDescription
$client\Zend_Http_Client
$applicationIdstring
methodpublicdelete(mixed $data,  $remainingRedirects = null) : void

DELETE entry with client object

Parameters
NameTypeDescription
$datamixed

The Zend_Gdata_App_Entry or URL to delete

$remainingRedirects
Throws
ExceptionDescription
\Zend_Gdata_App_Exception
\Zend_Gdata_App_HttpException
\Zend_Gdata_App_InvalidArgumentException
methodpublicenableRequestDebugLogging(string $logfile) : void

This method enables logging of requests by changing the Zend_Http_Client_Adapter used for performing the requests.

NOTE: This will not work if you have customized the adapter already to use a proxy server or other interface.
Parameters
NameTypeDescription
$logfilestring

The logfile to use when logging the requests

methodpublicgenerateIfMatchHeaderData( $data,  $allowWeek) : string | null

Returns the data for an If-Match header based on the current Etag property. If Etags are not supported by the server or cannot be extracted from the data, then null will be returned.

Parameters
NameTypeDescription
$data
$allowWeek
Returns
TypeDescription
string | null$data
methodpublicget(string $uri, array $extraHeaders = array()) : \Zend_Http_Response

GET a URI using client object.

Parameters
NameTypeDescription
$uristring

GET URI

$extraHeadersarray

Extra headers to add to the request, as an

   array of string-based key/value pairs.
Returns
TypeDescription
\Zend_Http_Response
Throws
ExceptionDescription
\Zend_Gdata_App_HttpException
methodpublicgetEntry(string $uri, string $className = 'Zend_Gdata_App_Entry') : string | \Zend_Gdata_App_Entry

Retrieve entry as string or object

Parameters
NameTypeDescription
$uristring
$classNamestring

The class which is used as the return type

Returns
TypeDescription
string | \Zend_Gdata_App_EntryReturns string only if the object mapping has been disabled explicitly by passing false to the useObjectMapping() function.
methodpublicgetFeed(string $uri, string $className = 'Zend_Gdata_App_Feed') : string | \Zend_Gdata_App_Feed

Retrieve feed as string or object

Parameters
NameTypeDescription
$uristring

The uri from which to retrieve the feed

$classNamestring

The class which is used as the return type

Returns
TypeDescription
string | \Zend_Gdata_App_FeedReturns string only if the object mapping has been disabled explicitly by passing false to the useObjectMapping() function.
methodpublicgetGzipEnabled() : boolean
static

Get the HTTP override state

Returns
TypeDescription
boolean
methodpublicgetHttpClient() : \Zend_Http_Client

Get the Zend_Http_Client object used for communication

Returns
TypeDescription
\Zend_Http_Client
methodpublicgetHttpMethodOverride() : boolean
static

Get the HTTP override state

Returns
TypeDescription
boolean
methodpublicgetMajorProtocolVersion() : int

Get the major protocol version that is in use.

Returns
TypeDescription
intThe major protocol version in use.
Details
See
 
methodpublicgetMaxRedirects() : int
static

Get the maximum number of redirects to follow during HTTP operations

Returns
TypeDescription
intMaximum number of redirects to follow
methodpublicgetMinorProtocolVersion() : \(int | \NULL)

Get the minor protocol version that is in use.

Returns
TypeDescription
\(int | \NULL)The major protocol version in use, or NULL if no minor version is specified.
Details
See
 
methodpublicgetNextFeed(\Zend_Gdata_App_Feed $feed, string $className = null) : \Zend_Gdata_App_Feed | null

Retrieve next set of results based on a given feed.

Parameters
NameTypeDescription
$feed\Zend_Gdata_App_Feed

The feed from which to retreive the next set of results.

$classNamestring

(optional) The class of feed to be returned.

     If null, the next feed (if found) will be the same class as
     the feed that was given as the first argument.
Returns
TypeDescription
\Zend_Gdata_App_Feed | nullReturns a Zend_Gdata_App_Feed or null if no next set of results exists.
methodpublicgetPreviousFeed(\Zend_Gdata_App_Feed $feed, string $className = null) : \Zend_Gdata_App_Feed | null

Retrieve previous set of results based on a given feed.

Parameters
NameTypeDescription
$feed\Zend_Gdata_App_Feed

The feed from which to retreive the previous set of results.

$classNamestring

(optional) The class of feed to be returned.

     If null, the previous feed (if found) will be the same class as
     the feed that was given as the first argument.
Returns
TypeDescription
\Zend_Gdata_App_Feed | nullReturns a Zend_Gdata_App_Feed or null if no previous set of results exists.
methodpublicgetStaticHttpClient() : \Zend_Http_Client
static

Gets the HTTP client object. If none is set, a new Zend_Http_Client will be used.

Returns
TypeDescription
\Zend_Http_Client
methodpublicgetVerboseExceptionMessages() : boolean
static

Get whether to use verbose exception messages

In the case of HTTP errors, use the body of the HTTP response in the exception message.
Returns
TypeDescription
boolean
methodpublicimport(string $uri, \Zend_Http_Client $client = null, string $className = 'Zend_Gdata_App_Feed', bool $useObjectMapping = true) : string | \Zend_Gdata_App_Feed
static

Imports a feed located at $uri.

Parameters
NameTypeDescription
$uristring
$client\Zend_Http_Client

The client used for communication

$classNamestring

The class which is used as the return type

$useObjectMappingbool

Enable/disable the use of XML to object mapping.

Returns
TypeDescription
string | \Zend_Gdata_App_FeedReturns string only if the fourth parameter ($useObjectMapping) is set to false.
Throws
ExceptionDescription
\Zend_Gdata_App_Exception
methodpublicimportFile(string $filename, string $className = 'Zend_Gdata_App_Feed', string $useIncludePath = false) : \Zend_Gdata_App_Feed
static

Imports a feed from a file located at $filename.

Parameters
NameTypeDescription
$filenamestring
$classNamestring

The class which is used as the return type

$useIncludePathstring

Whether the include_path should be searched

Returns
TypeDescription
\Zend_Gdata_App_Feed
Throws
ExceptionDescription
\Zend_Gdata_App_Exception
methodpublicimportString(string $string, string $className = 'Zend_Gdata_App_Feed',  $majorProtocolVersion = null,  $minorProtocolVersion = null) : \Zend_Gdata_App_Feed
static

Imports a feed represented by $string.

Parameters
NameTypeDescription
$stringstring
$classNamestring

The class which is used as the return type

$majorProtocolVersion
$minorProtocolVersion
Returns
TypeDescription
\Zend_Gdata_App_Feed
Throws
ExceptionDescription
\Zend_Gdata_App_Exception
methodpublicimportUrl(string $url, string $className = 'Zend_Gdata_App_Feed', array $extraHeaders = array()) : string | \Zend_Gdata_App_Feed

Imports the specified URL (non-statically).

Parameters
NameTypeDescription
$urlstring

The URL to import

$classNamestring

The class which is used as the return type

$extraHeadersarray

Extra headers to add to the request, as an

   array of string-based key/value pairs.
Returns
TypeDescription
string | \Zend_Gdata_App_FeedReturns string only if the object mapping has been disabled explicitly by passing false to the useObjectMapping() function.
Throws
ExceptionDescription
\Zend_Gdata_App_Exception
methodpublicinsertEntry(mixed $data, string $uri, string $className = 'Zend_Gdata_App_Entry', array $extraHeaders = array()) : \Zend_Gdata_App_Entry

Inserts an entry to a given URI and returns the response as a fully formed Entry.

Parameters
NameTypeDescription
$datamixed

The Zend_Gdata_App_Entry or XML to post

$uristring

POST URI

$classNamestring

The class of entry to be returned.

$extraHeadersarray

Extra headers to add to the request, as an

   array of string-based key/value pairs.
Returns
TypeDescription
\Zend_Gdata_App_EntryThe entry returned by the service after insertion.
methodpublicperformHttpRequest(string $method, string $url, array $headers = null, string $body = null, string $contentType = null, int $remainingRedirects = null) : \Zend_Http_Response

Performs a HTTP request using the specified method

Parameters
NameTypeDescription
$methodstring

The HTTP method for the request - 'GET', 'POST',

                  'PUT', 'DELETE'
$urlstring

The URL to which this request is being performed

$headersarray

An associative array of HTTP headers for this request

$bodystring

The body of the HTTP request

$contentTypestring

The value for the content type of the request body

$remainingRedirectsint

Number of redirects to follow if request s results in one

Returns
TypeDescription
\Zend_Http_ResponseThe response object
methodpublicpost(mixed $data, string $uri = null,  $remainingRedirects = null, string $contentType = null, array $extraHeaders = null) : \Zend_Http_Response

POST data with client object

Parameters
NameTypeDescription
$datamixed

The Zend_Gdata_App_Entry or XML to post

$uristring

POST URI

$remainingRedirects
$contentTypestring

Content-type of the data

$extraHeadersarray

Extra headers to add to the request, as an

   array of string-based key/value pairs.
Returns
TypeDescription
\Zend_Http_Response
Throws
ExceptionDescription
\Zend_Gdata_App_Exception
\Zend_Gdata_App_HttpException
\Zend_Gdata_App_InvalidArgumentException
methodpublicprepareRequest(string $method, string $url = null, array $headers = array(), mixed $data = null, string $contentTypeOverride = null) : array

Provides pre-processing for HTTP requests to APP services.

1. Checks the $data element and, if it's an entry, extracts the XML, multipart data, edit link (PUT,DELETE), etc. 2. If $data is a string, sets the default content-type header as 'application/atom+xml' if it's not already been set. 3. Adds a x-http-method override header and changes the HTTP method to 'POST' if necessary as per getHttpMethodOverride()
Parameters
NameTypeDescription
$methodstring

The HTTP method for the request - 'GET', 'POST',

                  'PUT', 'DELETE'
$urlstring

The URL to which this request is being performed,

               or null if found in $data
$headersarray

An associative array of HTTP headers for this request

$datamixed

The Zend_Gdata_App_Entry or XML for the body of the request

$contentTypeOverridestring

The override value for the content type of the request body

Returns
TypeDescription
arrayAn associative array containing the determined 'method', 'url', 'data', 'headers', 'contentType'
methodpublicput(mixed $data, string $uri = null,  $remainingRedirects = null, string $contentType = null, array $extraHeaders = null) : \Zend_Http_Response

PUT data with client object

Parameters
NameTypeDescription
$datamixed

The Zend_Gdata_App_Entry or XML to post

$uristring

PUT URI

$remainingRedirects
$contentTypestring

Content-type of the data

$extraHeadersarray

Extra headers to add to the request, as an

   array of string-based key/value pairs.
Returns
TypeDescription
\Zend_Http_Response
Throws
ExceptionDescription
\Zend_Gdata_App_Exception
\Zend_Gdata_App_HttpException
\Zend_Gdata_App_InvalidArgumentException
methodpublicregisterPackage(string $name) : void

Adds a Zend Framework package to the $_registeredPackages array.

This array is searched when using the magic __call method below to instantiante new objects.
Parameters
NameTypeDescription
$namestring

The name of the package (eg Zend_Gdata_App)

methodpublicretrieveAllEntriesForFeed(object $feed) : mixed

Retrieve all entries for a feed, iterating through pages as necessary.

Be aware that calling this function on a large dataset will take a significant amount of time to complete. In some cases this may cause execution to timeout without proper precautions in place.
Parameters
NameTypeDescription
$feedobject

The feed to iterate through.

Returns
TypeDescription
mixedA new feed of the same type as the one originally passed in, containing all relevent entries.
methodpublicsetGzipEnabled(boolean $enabled = false) : void
static

Toggle requesting gzip encoded responses

Parameters
NameTypeDescription
$enabledboolean

Whether or not to enable gzipped responses

methodpublicsetHttpClient(\Zend_Http_Client $client,  $applicationId = 'MyCompany-MyApp-1.0') : \Zend_Gdata_App

Set the Zend_Http_Client object used for communication

Parameters
NameTypeDescription
$client\Zend_Http_Client

The client to use for communication

$applicationId
Returns
TypeDescription
\Zend_Gdata_AppProvides a fluent interface
Throws
ExceptionDescription
\Zend_Gdata_App_HttpException
methodpublicsetHttpMethodOverride(boolean $override = true) : void
static

Toggle using POST instead of PUT and DELETE HTTP methods

Some feed implementations do not accept PUT and DELETE HTTP methods, or they can't be used because of proxies or other measures. This allows turning on using POST where PUT and DELETE would normally be used; in addition, an X-Method-Override header will be sent with a value of PUT or DELETE as appropriate.
Parameters
NameTypeDescription
$overrideboolean

Whether to override PUT and DELETE with POST.

methodpublicsetMajorProtocolVersion(int $value) : void

Set the major protocol version that should be used. Values < 1 will cause a Zend_Gdata_App_InvalidArgumentException to be thrown.

Parameters
NameTypeDescription
$valueint

The major protocol version to use.

Throws
ExceptionDescription
\Zend_Gdata_App_InvalidArgumentException
Details
See
 
methodpublicsetMaxRedirects(int $maxRedirects) : void
static

Set the maximum number of redirects to follow during HTTP operations

Parameters
NameTypeDescription
$maxRedirectsint

Maximum number of redirects to follow

methodpublicsetMinorProtocolVersion(\(int | \NULL) $value) : void

Set the minor protocol version that should be used. If set to NULL, no minor protocol version will be sent to the server. Values < 0 will cause a Zend_Gdata_App_InvalidArgumentException to be thrown.

Parameters
NameTypeDescription
$value\(int | \NULL)

The minor protocol version to use.

Throws
ExceptionDescription
\Zend_Gdata_App_InvalidArgumentException
Details
See
 
methodpublicsetStaticHttpClient(\Zend_Http_Client $httpClient) : void
static

Set the static HTTP client instance

Sets the static HTTP client object to use for retrieving the feed.
Parameters
NameTypeDescription
$httpClient\Zend_Http_Client
methodpublicsetVerboseExceptionMessages(boolean $verbose) : void
static

Set whether to use verbose exception messages

In the case of HTTP errors, use the body of the HTTP response in the exception message.
Parameters
NameTypeDescription
$verboseboolean

Whether to use verbose exception messages

methodpublicupdateEntry(mixed $data,  $uri = null,  $className = null, array $extraHeaders = array()) : \Zend_Gdata_App_Entry

Update an entry

Parameters
NameTypeDescription
$datamixed

Zend_Gdata_App_Entry or XML (w/ID and link rel='edit')

$uri
$className
$extraHeadersarray

Extra headers to add to the request, as an

   array of string-based key/value pairs.
Returns
TypeDescription
\Zend_Gdata_App_EntryThe entry returned from the server
Throws
ExceptionDescription
\Zend_Gdata_App_Exception
methodpublicuseObjectMapping(boolean $value) : void

Enable/disable the use of XML to object mapping.

Parameters
NameTypeDescription
$valueboolean

Pass in true to use the XML to object mapping. Pass in false or null to disable it.

methodpublicusingObjectMapping() : boolean

Determine whether service object is using XML to object mapping.

Returns
TypeDescription
booleanTrue if service object is using XML to object mapping, false otherwise.
Documentation was generated by phpDocumentor 2.2.0 .