\Guzzle\Service\BuilderServiceBuilder

Class that holds an event dispatcher

Clients and data can be set, retrieved, and removed by accessing the service builder like an associative array.

Summary

Methods
Properties
Constants
getAllEvents()
setEventDispatcher()
getEventDispatcher()
dispatch()
addSubscriber()
factory()
__construct()
unserialize()
serialize()
addGlobalPlugin()
getData()
get()
set()
offsetSet()
offsetUnset()
offsetExists()
offsetGet()
No public properties found
No constants found
No protected methods found
$eventDispatcher
$builderConfig
$clients
$cachedFactory
$plugins
N/A
No private methods found
No private properties found
N/A

Properties

$builderConfig

$builderConfig : array

Type

array — Service builder configuration data

$clients

$clients : array

Type

array — Instantiated client objects

$plugins

$plugins : array

Type

array — Plugins to attach to each client created by the service builder

Methods

getAllEvents()

getAllEvents() : array

Get a list of all of the events emitted from the class

Returns

array

dispatch()

dispatch(string  $eventName, array  $context = array()) : \Guzzle\Common\Event

Helper to dispatch Guzzle events and set the event name on the event

Parameters

string $eventName

Name of the event to dispatch

array $context

Context of the event

Returns

\Guzzle\Common\Event

Returns the created event object

factory()

factory(array|string  $config = null, array  $globalParameters = array()) : \Guzzle\Service\Builder\ServiceBuilderInterface

Create a new ServiceBuilder using configuration data sourced from an array, .js|.json or .php file.

Parameters

array|string $config

The full path to an .json|.js or .php file, or an associative array

array $globalParameters

Array of global parameters to pass to every service as it is instantiated.

Throws

\Guzzle\Service\Exception\ServiceBuilderException

if a file cannot be opened

\Guzzle\Service\Exception\ServiceNotFoundException

when trying to extend a missing client

Returns

\Guzzle\Service\Builder\ServiceBuilderInterface

__construct()

__construct(array  $serviceBuilderConfig = array()) 

Parameters

array $serviceBuilderConfig

Service configuration settings:

  • name: Name of the service
  • class: Client class to instantiate using a factory method
  • params: array of key value pair configuration settings for the builder

unserialize()

unserialize(  $serialized) 

Parameters

$serialized

serialize()

serialize() 

getData()

getData(string  $name) : array|null

Get data from the service builder without triggering the building of a service

Parameters

string $name

Name of the service to retrieve

Returns

array|null

get()

get(string  $name, boolean|array  $throwAway = false) : \Guzzle\Service\ClientInterface|mixed

Get a ClientInterface object or arbitrary data from the service builder

Parameters

string $name

Name of the registered service or data to retrieve

boolean|array $throwAway

Only pertains to retrieving client objects built using a configuration array. Set to TRUE to not store the client for later retrieval from the ServiceBuilder. If an array is specified, that data will overwrite the configured params of the client if the client implements {@see \Guzzle\Common\FromConfigInterface} and will not store the client for later retrieval.

Returns

\Guzzle\Service\ClientInterface|mixed

set()

set(string  $key, mixed  $service) : \Guzzle\Service\Builder\ServiceBuilderInterface

Register a service or arbitrary data by name with the service builder

Parameters

string $key

Name of the client or data to register

mixed $service

Client configuration array or arbitrary data to register. The client configuration array must include a 'class' (string) and 'params' (array) key.

Returns

\Guzzle\Service\Builder\ServiceBuilderInterface

offsetSet()

offsetSet(  $offset,   $value) 

Parameters

$offset
$value

offsetUnset()

offsetUnset(  $offset) 

Parameters

$offset

offsetExists()

offsetExists(  $offset) 

Parameters

$offset

offsetGet()

offsetGet(  $offset) 

Parameters

$offset