Zend Framework  3.0
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Subscriber Class Reference

Public Member Functions

 __construct ($options=null)
 Constructor; accepts an array or Traversable instance to preset options for the Subscriber without calling all supported setter methods in turn.
 
 setOptions ($options)
 Process any injected configuration options.
 
 setTopicUrl ($url)
 Set the topic URL (RSS or Atom feed) to which the intended (un)subscribe event will relate.
 
 getTopicUrl ()
 Set the topic URL (RSS or Atom feed) to which the intended (un)subscribe event will relate.
 
 setLeaseSeconds ($seconds)
 Set the number of seconds for which any subscription will remain valid.
 
 getLeaseSeconds ()
 Get the number of lease seconds on subscriptions.
 
 setCallbackUrl ($url)
 Set the callback URL to be used by Hub Servers when communicating with this Subscriber.
 
 getCallbackUrl ()
 Get the callback URL to be used by Hub Servers when communicating with this Subscriber.
 
 setPreferredVerificationMode ($mode)
 Set preferred verification mode (sync or async).
 
 getPreferredVerificationMode ()
 Get preferred verification mode (sync or async).
 
 addHubUrl ($url)
 Add a Hub Server URL supported by Publisher.
 
 addHubUrls (array $urls)
 Add an array of Hub Server URLs supported by Publisher.
 
 removeHubUrl ($url)
 Remove a Hub Server URL.
 
 getHubUrls ()
 Return an array of unique Hub Server URLs currently available.
 
 addAuthentication ($url, array $authentication)
 Add authentication credentials for a given URL.
 
 addAuthentications (array $authentications)
 Add authentication credentials for hub URLs.
 
 getAuthentications ()
 Get all hub URL authentication credentials.
 
 usePathParameter ($bool=true)
 Set flag indicating whether or not to use a path parameter.
 
 setParameter ($name, $value=null)
 Add an optional parameter to the (un)subscribe requests.
 
 setParameters (array $parameters)
 Add an optional parameter to the (un)subscribe requests.
 
 removeParameter ($name)
 Remove an optional parameter for the (un)subscribe requests.
 
 getParameters ()
 Return an array of optional parameters for (un)subscribe requests.
 
 setStorage (Model\SubscriptionPersistenceInterface $storage)
 Sets an instance of Zend used to background save any verification tokens associated with a subscription or other.
 
 getStorage ()
 Gets an instance of Zend used to background save any verification tokens associated with a subscription or other.
 
 subscribeAll ()
 Subscribe to one or more Hub Servers using the stored Hub URLs for the given Topic URL (RSS or Atom feed)
 
 unsubscribeAll ()
 Unsubscribe from one or more Hub Servers using the stored Hub URLs for the given Topic URL (RSS or Atom feed)
 
 isSuccess ()
 Returns a boolean indicator of whether the notifications to Hub Servers were ALL successful.
 
 getErrors ()
 Return an array of errors met from any failures, including keys: 'response' => the Zend object from the failure 'hubUrl' => the URL of the Hub Server whose notification failed.
 
 getAsyncHubs ()
 Return an array of Hub Server URLs who returned a response indicating operation in Asynchronous Verification Mode, i.e.
 
 setTestStaticToken ($token)
 

Protected Member Functions

 _doRequest ($mode)
 Executes an (un)subscribe request.
 
 _getHttpClient ()
 Get a basic prepared HTTP client for use.
 
 _getRequestParameters ($hubUrl, $mode)
 Return a list of standard protocol/optional parameters for addition to client's POST body that are specific to the current Hub Server URL.
 
 _generateVerifyToken ()
 Simple helper to generate a verification token used in (un)subscribe requests to a Hub Server.
 
 _generateSubscriptionKey (array $params, $hubUrl)
 Simple helper to generate a verification token used in (un)subscribe requests to a Hub Server.
 
 _urlEncode (array $params)
 URL Encode an array of parameters.
 
 _toByteValueOrderedString (array $params)
 Order outgoing parameters.
 

Protected Attributes

 $hubUrls = []
 
 $parameters = []
 
 $topicUrl = ''
 
 $callbackUrl = ''
 
 $leaseSeconds = null
 
 $preferredVerificationMode = PubSubHubbub::VERIFICATION_MODE_SYNC
 
 $errors = []
 
 $asyncHubs = []
 
 $storage = null
 
 $authentications = []
 
 $usePathParameter = false
 
 $testStaticToken = null
 This is STRICTLY for testing purposes only...
 

Constructor & Destructor Documentation

__construct (   $options = null)

Constructor; accepts an array or Traversable instance to preset options for the Subscriber without calling all supported setter methods in turn.

Parameters
array | Traversable$options

Member Function Documentation

_doRequest (   $mode)
protected

Executes an (un)subscribe request.

Parameters
string$mode
Returns
void
Exceptions
Exception\RuntimeException

At first I thought it was needed, but the backend storage will allow tracking async without any user interference. It's left here in case the user is interested in knowing what Hubs are using async verification modes so they may update Models and move these to asynchronous processes.

_generateSubscriptionKey ( array  $params,
  $hubUrl 
)
protected

Simple helper to generate a verification token used in (un)subscribe requests to a Hub Server.

Parameters
array$params
string$hubUrlThe Hub Server URL for which this token will apply
Returns
string
_generateVerifyToken ( )
protected

Simple helper to generate a verification token used in (un)subscribe requests to a Hub Server.

Follows no particular method, which means it might be improved/changed in future.

Returns
string
_getHttpClient ( )
protected

Get a basic prepared HTTP client for use.

Returns
_getRequestParameters (   $hubUrl,
  $mode 
)
protected

Return a list of standard protocol/optional parameters for addition to client's POST body that are specific to the current Hub Server URL.

Parameters
string$hubUrl
string$mode
Returns
string
Exceptions
Exception\InvalidArgumentException

Establish a persistent verify_token and attach key to callback URL's path/query_string

_toByteValueOrderedString ( array  $params)
protected

Order outgoing parameters.

Parameters
array$params
Returns
array
_urlEncode ( array  $params)
protected

URL Encode an array of parameters.

Parameters
array$params
Returns
array
addAuthentication (   $url,
array  $authentication 
)

Add authentication credentials for a given URL.

Parameters
string$url
array$authentication
Returns
Subscriber
Exceptions
Exception\InvalidArgumentException
addAuthentications ( array  $authentications)

Add authentication credentials for hub URLs.

Parameters
array$authentications
Returns
Subscriber
addHubUrl (   $url)

Add a Hub Server URL supported by Publisher.

Parameters
string$url
Returns
Subscriber
Exceptions
Exception\InvalidArgumentException
addHubUrls ( array  $urls)

Add an array of Hub Server URLs supported by Publisher.

Parameters
array$urls
Returns
Subscriber
getAsyncHubs ( )

Return an array of Hub Server URLs who returned a response indicating operation in Asynchronous Verification Mode, i.e.

they will not confirm any (un)subscription immediately but at a later time (Hubs may be doing this as a batch process when load balancing)

Returns
array
getAuthentications ( )

Get all hub URL authentication credentials.

Returns
array
getCallbackUrl ( )

Get the callback URL to be used by Hub Servers when communicating with this Subscriber.

Returns
string
Exceptions
Exception\RuntimeException
getErrors ( )

Return an array of errors met from any failures, including keys: 'response' => the Zend object from the failure 'hubUrl' => the URL of the Hub Server whose notification failed.

Returns
array
getHubUrls ( )

Return an array of unique Hub Server URLs currently available.

Returns
array
getLeaseSeconds ( )

Get the number of lease seconds on subscriptions.

Returns
int
getParameters ( )

Return an array of optional parameters for (un)subscribe requests.

Returns
array
getPreferredVerificationMode ( )

Get preferred verification mode (sync or async).

Returns
string
getStorage ( )

Gets an instance of Zend used to background save any verification tokens associated with a subscription or other.

Returns
Model
Exceptions
Exception\RuntimeException
getTopicUrl ( )

Set the topic URL (RSS or Atom feed) to which the intended (un)subscribe event will relate.

Returns
string
Exceptions
Exception\RuntimeException
isSuccess ( )

Returns a boolean indicator of whether the notifications to Hub Servers were ALL successful.

If even one failed, FALSE is returned.

Returns
bool
removeHubUrl (   $url)

Remove a Hub Server URL.

Parameters
string$url
Returns
Subscriber
removeParameter (   $name)

Remove an optional parameter for the (un)subscribe requests.

Parameters
string$name
Returns
Subscriber
Exceptions
Exception\InvalidArgumentException
setCallbackUrl (   $url)

Set the callback URL to be used by Hub Servers when communicating with this Subscriber.

Parameters
string$url
Returns
Subscriber
Exceptions
Exception\InvalidArgumentException
setLeaseSeconds (   $seconds)

Set the number of seconds for which any subscription will remain valid.

Parameters
int$seconds
Returns
Subscriber
Exceptions
Exception\InvalidArgumentException
setOptions (   $options)

Process any injected configuration options.

Parameters
array | Traversable$options
Returns
Subscriber
Exceptions
Exception\InvalidArgumentException
setParameter (   $name,
  $value = null 
)

Add an optional parameter to the (un)subscribe requests.

Parameters
string$name
string | null$value
Returns
Subscriber
Exceptions
Exception\InvalidArgumentException
setParameters ( array  $parameters)

Add an optional parameter to the (un)subscribe requests.

Parameters
array$parameters
Returns
Subscriber
setPreferredVerificationMode (   $mode)

Set preferred verification mode (sync or async).

By default, this Subscriber prefers synchronous verification, but does support asynchronous if that's the Hub Server's utilised mode.

Zend will always send both modes, whose order of occurrence in the parameter list determines this preference.

Parameters
string$modeShould be 'sync' or 'async'
Returns
Subscriber
Exceptions
Exception\InvalidArgumentException
setStorage ( Model\SubscriptionPersistenceInterface  $storage)

Sets an instance of Zend used to background save any verification tokens associated with a subscription or other.

Parameters
Model\SubscriptionPersistenceInterface$storage
Returns
Subscriber
setTestStaticToken (   $token)
final
setTopicUrl (   $url)

Set the topic URL (RSS or Atom feed) to which the intended (un)subscribe event will relate.

Parameters
string$url
Returns
Subscriber
Exceptions
Exception\InvalidArgumentException
subscribeAll ( )

Subscribe to one or more Hub Servers using the stored Hub URLs for the given Topic URL (RSS or Atom feed)

Returns
void
unsubscribeAll ( )

Unsubscribe from one or more Hub Servers using the stored Hub URLs for the given Topic URL (RSS or Atom feed)

Returns
void
usePathParameter (   $bool = true)

Set flag indicating whether or not to use a path parameter.

Parameters
bool$bool
Returns
Subscriber

Member Data Documentation

$asyncHubs = []
protected
$authentications = []
protected
$callbackUrl = ''
protected
$errors = []
protected
$hubUrls = []
protected
$leaseSeconds = null
protected
$parameters = []
protected
$preferredVerificationMode = PubSubHubbub::VERIFICATION_MODE_SYNC
protected
$storage = null
protected
$testStaticToken = null
protected

This is STRICTLY for testing purposes only...

$topicUrl = ''
protected
$usePathParameter = false
protected