Zend Framework  1.12
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Attributes | Static Protected Attributes | List of all members
Zend_Gdata_App Class Reference

Public Member Functions

 __construct ($client=null, $applicationId= 'MyCompany-MyApp-1.0')
 Create Gdata object.
 
 registerPackage ($name)
 Adds a Zend Framework package to the $_registeredPackages array.
 
 getFeed ($uri, $className='Zend_Gdata_App_Feed')
 Retrieve feed as string or object.
 
 getEntry ($uri, $className='Zend_Gdata_App_Entry')
 Retrieve entry as string or object.
 
 getHttpClient ()
 Get the Zend_Http_Client object used for communication.
 
 setHttpClient ($client, $applicationId= 'MyCompany-MyApp-1.0')
 Set the Zend_Http_Client object used for communication.
 
 setMajorProtocolVersion ($value)
 Set the major protocol version that should be used.
 
 getMajorProtocolVersion ()
 Get the major protocol version that is in use.
 
 setMinorProtocolVersion ($value)
 Set the minor protocol version that should be used.
 
 getMinorProtocolVersion ()
 Get the minor protocol version that is in use.
 
 prepareRequest ($method, $url=null, $headers=array(), $data=null, $contentTypeOverride=null)
 Provides pre-processing for HTTP requests to APP services.
 
 performHttpRequest ($method, $url, $headers=null, $body=null, $contentType=null, $remainingRedirects=null)
 Performs a HTTP request using the specified method.
 
 importUrl ($url, $className='Zend_Gdata_App_Feed', $extraHeaders=array())
 Imports the specified URL (non-statically).
 
 get ($uri, $extraHeaders=array())
 GET a URI using client object.
 
 post ($data, $uri=null, $remainingRedirects=null, $contentType=null, $extraHeaders=null)
 POST data with client object.
 
 put ($data, $uri=null, $remainingRedirects=null, $contentType=null, $extraHeaders=null)
 PUT data with client object.
 
 delete ($data, $remainingRedirects=null)
 DELETE entry with client object.
 
 insertEntry ($data, $uri, $className='Zend_Gdata_App_Entry', $extraHeaders=array())
 Inserts an entry to a given URI and returns the response as a fully formed Entry.
 
 updateEntry ($data, $uri=null, $className=null, $extraHeaders=array())
 Update an entry.
 
 __call ($method, $args)
 Provides a magic factory method to instantiate new objects with shorter syntax than would otherwise be required by the Zend Framework naming conventions.
 
 retrieveAllEntriesForFeed ($feed)
 Retrieve all entries for a feed, iterating through pages as necessary.
 
 enableRequestDebugLogging ($logfile)
 This method enables logging of requests by changing the Zend_Http_Client_Adapter used for performing the requests.
 
 getNextFeed ($feed, $className=null)
 Retrieve next set of results based on a given feed.
 
 getPreviousFeed ($feed, $className=null)
 Retrieve previous set of results based on a given feed.
 
 generateIfMatchHeaderData ($data, $allowWeek)
 Returns the data for an If-Match header based on the current Etag property.
 
 usingObjectMapping ()
 Determine whether service object is using XML to object mapping.
 
 useObjectMapping ($value)
 Enable/disable the use of XML to object mapping.
 

Static Public Member Functions

static setStaticHttpClient (Zend_Http_Client $httpClient)
 Set the static HTTP client instance.
 
static getStaticHttpClient ()
 Gets the HTTP client object.
 
static setHttpMethodOverride ($override=true)
 Toggle using POST instead of PUT and DELETE HTTP methods.
 
static getHttpMethodOverride ()
 Get the HTTP override state.
 
static setGzipEnabled ($enabled=false)
 Toggle requesting gzip encoded responses.
 
static getGzipEnabled ()
 Get the HTTP override state.
 
static getVerboseExceptionMessages ()
 Get whether to use verbose exception messages.
 
static setVerboseExceptionMessages ($verbose)
 Set whether to use verbose exception messages.
 
static setMaxRedirects ($maxRedirects)
 Set the maximum number of redirects to follow during HTTP operations.
 
static getMaxRedirects ()
 Get the maximum number of redirects to follow during HTTP operations.
 
static import ($uri, $client=null, $className='Zend_Gdata_App_Feed', $useObjectMapping=true)
 Imports a feed located at $uri.
 
static importString ($string, $className='Zend_Gdata_App_Feed', $majorProtocolVersion=null, $minorProtocolVersion=null)
 Imports a feed represented by $string.
 
static importFile ($filename, $className='Zend_Gdata_App_Feed', $useIncludePath=false)
 Imports a feed from a file located at $filename.
 

Public Attributes

const DEFAULT_MAJOR_PROTOCOL_VERSION = 1
 Default major protocol version.
 
const DEFAULT_MINOR_PROTOCOL_VERSION = null
 Default minor protocol version.
 

Protected Attributes

 $_httpClient
 
 $_defaultPostUri = null
 
 $_registeredPackages
 
 $_majorProtocolVersion
 Indicates the major protocol version that should be used.
 
 $_minorProtocolVersion
 Indicates the minor protocol version that should be used.
 
 $_useObjectMapping = true
 

Static Protected Attributes

static $_staticHttpClient = null
 
static $_httpMethodOverride = false
 
static $_gzipEnabled = false
 
static $_verboseExceptionMessages = true
 
static $_maxRedirects = 5
 

Constructor & Destructor Documentation

__construct (   $client = null,
  $applicationId = 'MyCompany-MyApp-1.0' 
)

Create Gdata object.

Parameters
Zend_Http_Client$client
string$applicationId

Member Function Documentation

__call (   $method,
  $args 
)

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
string$methodThe method name being called
array$argsThe arguments passed to the call
Exceptions
Zend_Gdata_App_Exception
delete (   $data,
  $remainingRedirects = null 
)

DELETE entry with client object.

Parameters
mixed$dataThe Zend_Gdata_App_Entry or URL to delete
Returns
void
Exceptions
Zend_Gdata_App_Exception
Zend_Gdata_App_HttpException
Zend_Gdata_App_InvalidArgumentException
enableRequestDebugLogging (   $logfile)

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
string$logfileThe logfile to use when logging the requests
generateIfMatchHeaderData (   $data,
  $allowWeek 
)

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
boolean$allowWeakIf false, then if a weak Etag is detected, then return null rather than the Etag.
Returns
string|null $data
get (   $uri,
  $extraHeaders = array() 
)

GET a URI using client object.

Parameters
string$uriGET URI
array$extraHeadersExtra headers to add to the request, as an array of string-based key/value pairs.
Exceptions
Zend_Gdata_App_HttpException
Returns
Zend_Http_Response
getEntry (   $uri,
  $className = 'Zend_Gdata_App_Entry' 
)

Retrieve entry as string or object.

Parameters
string$uri
string$classNameThe class which is used as the return type
Returns
string|Zend_Gdata_App_Entry Returns string only if the object mapping has been disabled explicitly by passing false to the useObjectMapping() function.
getFeed (   $uri,
  $className = 'Zend_Gdata_App_Feed' 
)

Retrieve feed as string or object.

Parameters
string$uriThe uri from which to retrieve the feed
string$classNameThe class which is used as the return type
Returns
string|Zend_Gdata_App_Feed Returns string only if the object mapping has been disabled explicitly by passing false to the useObjectMapping() function.
static getGzipEnabled ( )
static

Get the HTTP override state.

Returns
boolean
getHttpClient ( )

Get the Zend_Http_Client object used for communication.

Returns
Zend_Http_Client
static getHttpMethodOverride ( )
static

Get the HTTP override state.

Returns
boolean
getMajorProtocolVersion ( )

Get the major protocol version that is in use.

See Also
_majorProtocolVersion
Returns
int The major protocol version in use.
static getMaxRedirects ( )
static

Get the maximum number of redirects to follow during HTTP operations.

Returns
int Maximum number of redirects to follow
getMinorProtocolVersion ( )

Get the minor protocol version that is in use.

See Also
_minorProtocolVersion
Returns
(int|NULL) The major protocol version in use, or NULL if no minor version is specified.
getNextFeed (   $feed,
  $className = null 
)

Retrieve next set of results based on a given feed.

Parameters
Zend_Gdata_App_Feed$feedThe feed from which to retreive the next set of results.
string$className(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
Zend_Gdata_App_Feed|null Returns a Zend_Gdata_App_Feed or null if no next set of results exists.
getPreviousFeed (   $feed,
  $className = null 
)

Retrieve previous set of results based on a given feed.

Parameters
Zend_Gdata_App_Feed$feedThe feed from which to retreive the previous set of results.
string$className(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
Zend_Gdata_App_Feed|null Returns a Zend_Gdata_App_Feed or null if no previous set of results exists.
static getStaticHttpClient ( )
static

Gets the HTTP client object.

If none is set, a new Zend_Http_Client will be used.

Returns
Zend_Http_Client
static getVerboseExceptionMessages ( )
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
boolean
static import (   $uri,
  $client = null,
  $className = 'Zend_Gdata_App_Feed',
  $useObjectMapping = true 
)
static

Imports a feed located at $uri.

Parameters
string$uri
Zend_Http_Client$clientThe client used for communication
string$classNameThe class which is used as the return type
bool$useObjectMappingEnable/disable the use of XML to object mapping.
Exceptions
Zend_Gdata_App_Exception
Returns
string|Zend_Gdata_App_Feed Returns string only if the fourth parameter ($useObjectMapping) is set to false.
static importFile (   $filename,
  $className = 'Zend_Gdata_App_Feed',
  $useIncludePath = false 
)
static

Imports a feed from a file located at $filename.

Parameters
string$filename
string$classNameThe class which is used as the return type
string$useIncludePathWhether the include_path should be searched
Exceptions
Zend_Gdata_App_Exception
Returns
Zend_Gdata_App_Feed
static importString (   $string,
  $className = 'Zend_Gdata_App_Feed',
  $majorProtocolVersion = null,
  $minorProtocolVersion = null 
)
static

Imports a feed represented by $string.

Parameters
string$string
string$classNameThe class which is used as the return type
integer$majorProcolVersion(optional) The major protocol version of the data model object that is to be created.
integer$minorProcolVersion(optional) The minor protocol version of the data model object that is to be created.
Exceptions
Zend_Gdata_App_Exception
Returns
Zend_Gdata_App_Feed
importUrl (   $url,
  $className = 'Zend_Gdata_App_Feed',
  $extraHeaders = array() 
)

Imports the specified URL (non-statically).

Parameters
string$urlThe URL to import
string$classNameThe class which is used as the return type
array$extraHeadersExtra headers to add to the request, as an array of string-based key/value pairs.
Exceptions
Zend_Gdata_App_Exception
Returns
string|Zend_Gdata_App_Feed Returns string only if the object mapping has been disabled explicitly by passing false to the useObjectMapping() function.
insertEntry (   $data,
  $uri,
  $className = 'Zend_Gdata_App_Entry',
  $extraHeaders = array() 
)

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

Parameters
mixed$dataThe Zend_Gdata_App_Entry or XML to post
string$uriPOST URI
string$classNameThe class of entry to be returned.
array$extraHeadersExtra headers to add to the request, as an array of string-based key/value pairs.
Returns
Zend_Gdata_App_Entry The entry returned by the service after insertion.
performHttpRequest (   $method,
  $url,
  $headers = null,
  $body = null,
  $contentType = null,
  $remainingRedirects = null 
)

Performs a HTTP request using the specified method.

Parameters
string$methodThe HTTP method for the request - 'GET', 'POST', 'PUT', 'DELETE'
string$urlThe URL to which this request is being performed
array$headersAn associative array of HTTP headers for this request
string$bodyThe body of the HTTP request
string$contentTypeThe value for the content type of the request body
int$remainingRedirectsNumber of redirects to follow if request s results in one
Returns
Zend_Http_Response The response object
post (   $data,
  $uri = null,
  $remainingRedirects = null,
  $contentType = null,
  $extraHeaders = null 
)

POST data with client object.

Parameters
mixed$dataThe Zend_Gdata_App_Entry or XML to post
string$uriPOST URI
array$headersAdditional HTTP headers to insert.
string$contentTypeContent-type of the data
array$extraHeadersExtra headers to add to the request, as an array of string-based key/value pairs.
Returns
Zend_Http_Response
Exceptions
Zend_Gdata_App_Exception
Zend_Gdata_App_HttpException
Zend_Gdata_App_InvalidArgumentException
prepareRequest (   $method,
  $url = null,
  $headers = array(),
  $data = null,
  $contentTypeOverride = null 
)

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
string$methodThe HTTP method for the request - 'GET', 'POST', 'PUT', 'DELETE'
string$urlThe URL to which this request is being performed, or null if found in $data
array$headersAn associative array of HTTP headers for this request
mixed$dataThe Zend_Gdata_App_Entry or XML for the body of the request
string$contentTypeOverrideThe override value for the content type of the request body
Returns
array An associative array containing the determined 'method', 'url', 'data', 'headers', 'contentType'
put (   $data,
  $uri = null,
  $remainingRedirects = null,
  $contentType = null,
  $extraHeaders = null 
)

PUT data with client object.

Parameters
mixed$dataThe Zend_Gdata_App_Entry or XML to post
string$uriPUT URI
array$headersAdditional HTTP headers to insert.
string$contentTypeContent-type of the data
array$extraHeadersExtra headers to add to the request, as an array of string-based key/value pairs.
Returns
Zend_Http_Response
Exceptions
Zend_Gdata_App_Exception
Zend_Gdata_App_HttpException
Zend_Gdata_App_InvalidArgumentException
registerPackage (   $name)

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
string$nameThe name of the package (eg Zend_Gdata_App)
Returns
void
retrieveAllEntriesForFeed (   $feed)

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
object$feedThe feed to iterate through.
Returns
mixed A new feed of the same type as the one originally passed in, containing all relevent entries.
static setGzipEnabled (   $enabled = false)
static

Toggle requesting gzip encoded responses.

Parameters
boolean$enabledWhether or not to enable gzipped responses
Returns
void
setHttpClient (   $client,
  $applicationId = 'MyCompany-MyApp-1.0' 
)

Set the Zend_Http_Client object used for communication.

Parameters
Zend_Http_Client$clientThe client to use for communication
Exceptions
Zend_Gdata_App_HttpException
Returns
Zend_Gdata_App Provides a fluent interface
static setHttpMethodOverride (   $override = true)
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
boolean$overrideWhether to override PUT and DELETE with POST.
Returns
void
setMajorProtocolVersion (   $value)

Set the major protocol version that should be used.

Values < 1 will cause a Zend_Gdata_App_InvalidArgumentException to be thrown.

See Also
_majorProtocolVersion
Parameters
int$valueThe major protocol version to use.
Exceptions
Zend_Gdata_App_InvalidArgumentException
static setMaxRedirects (   $maxRedirects)
static

Set the maximum number of redirects to follow during HTTP operations.

Parameters
int$maxRedirectsMaximum number of redirects to follow
Returns
void
setMinorProtocolVersion (   $value)

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.

See Also
_minorProtocolVersion
Parameters
(int|NULL)$value The minor protocol version to use.
Exceptions
Zend_Gdata_App_InvalidArgumentException
static setStaticHttpClient ( Zend_Http_Client  $httpClient)
static

Set the static HTTP client instance.

Sets the static HTTP client object to use for retrieving the feed.

Parameters
Zend_Http_Client$httpClient
Returns
void
static setVerboseExceptionMessages (   $verbose)
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
boolean$verboseWhether to use verbose exception messages
updateEntry (   $data,
  $uri = null,
  $className = null,
  $extraHeaders = array() 
)

Update an entry.

Parameters
mixed$dataZend_Gdata_App_Entry or XML (w/ID and link rel='edit')
string|nullThe URI to send requests to, or null if $data contains the URI.
string|nullThe name of the class that should be deserialized from the server response. If null, then 'Zend_Gdata_App_Entry' will be used.
array$extraHeadersExtra headers to add to the request, as an array of string-based key/value pairs.
Returns
Zend_Gdata_App_Entry The entry returned from the server
Exceptions
Zend_Gdata_App_Exception
useObjectMapping (   $value)

Enable/disable the use of XML to object mapping.

Parameters
boolean$valuePass in true to use the XML to object mapping. Pass in false or null to disable it.
Returns
void
usingObjectMapping ( )

Determine whether service object is using XML to object mapping.

Returns
boolean True if service object is using XML to object mapping, false otherwise.

Member Data Documentation

$_defaultPostUri = null
protected
$_gzipEnabled = false
staticprotected
$_httpClient
protected
$_httpMethodOverride = false
staticprotected
$_majorProtocolVersion
protected

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.

See Also
setMajorProtocolVersion()
getMajorProtocolVersion()
$_maxRedirects = 5
staticprotected
$_minorProtocolVersion
protected

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.

See Also
setMinorProtocolVersion()
getMinorProtocolVersion()
$_registeredPackages
protected
Initial value:
= array(
'Zend_Gdata_App_Extension',
'Zend_Gdata_App')
$_staticHttpClient = null
staticprotected
$_useObjectMapping = true
protected
$_verboseExceptionMessages = true
staticprotected
const DEFAULT_MAJOR_PROTOCOL_VERSION = 1

Default major protocol version.

See Also
_majorProtocolVersion
const DEFAULT_MINOR_PROTOCOL_VERSION = null

Default minor protocol version.

See Also
_minorProtocolVersion