Class ServiceBuilder
Class that holds an event dispatcher
Clients and data can be set, retrieved, and removed by accessing the service builder like an associative array.
- Guzzle\Common\AbstractHasDispatcher implements Guzzle\Common\HasDispatcherInterface
-
Guzzle\Service\Builder\ServiceBuilder
implements
Guzzle\Service\Builder\ServiceBuilderInterface,
ArrayAccess,
Serializable
Direct known subclasses
Methods summary
-
public staticfactory ( array|string $config = null, array $globalParameters = array() )Create a new ServiceBuilder using configuration data sourced from an array, .js|.json or .php file.
-
public__construct ( array $serviceBuilderConfig = array() ) -
public staticgetAllEvents ( )Get a list of all of the events emitted from the class
-
publicunserialize ( mixed $serialized ) -
publicserialize ( ) -
publicaddGlobalPlugin ( Symfony\Component\EventDispatcher\EventSubscriberInterface $plugin )Attach a plugin to every client created by the builder
-
publicgetData ( string $name )Get data from the service builder without triggering the building of a service
-
publicget ( string $name, bool|array $throwAway = false )Get a ClientInterface object or arbitrary data from the service builder
-
publicset ( string $key, mixed $service )Register a service or arbitrary data by name with the service builder
-
publicoffsetSet ( mixed $offset, mixed $value ) -
publicoffsetUnset ( mixed $offset ) -
publicoffsetExists ( mixed $offset ) -
publicoffsetGet ( mixed $offset )
Methods detail
public static
Guzzle\Service\Builder\ServiceBuilderInterface
factory( array|string $config = null, array $globalParameters = array() )
Create a new ServiceBuilder using configuration data sourced from an array, .js|.json or .php file.
Parameters
- $config
array|string
$config The full path to an .json|.js or .php file, or an associative array- $globalParameters
array
$globalParameters Array of global parameters to pass to every service as it is instantiated.
Returns
Throws
Guzzle\Service\Exception\ServiceBuilderExceptionif a file cannot be opened
Guzzle\Service\Exception\ServiceNotFoundExceptionwhen trying to extend a missing client
Parameters
- $serviceBuilderConfig
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
Get a list of all of the events emitted from the class
Returns
arrayOverrides
Implementation of
Implementation of
public
Guzzle\Service\Builder\ServiceBuilder
addGlobalPlugin( Symfony\Component\EventDispatcher\EventSubscriberInterface $plugin )
Attach a plugin to every client created by the builder
Parameters
- $plugin
Symfony\Component\EventDispatcher\EventSubscriberInterface
$plugin Plugin to attach to each client
Returns
Get data from the service builder without triggering the building of a service
Parameters
- $name
string
$name Name of the service to retrieve
Returns
array|nullGet a ClientInterface object or arbitrary data from the service builder
Parameters
- $name
string
$name Name of the registered service or data to retrieve- $throwAway
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 implementsGuzzle\Common\FromConfigInterfaceand will not store the client for later retrieval.
Returns
Throws
Guzzle\Service\Exception\ServiceNotFoundExceptionwhen a client or data cannot be found by the given name
Implementation of
Register a service or arbitrary data by name with the service builder
Parameters
- $key
string
$key Name of the client or data to register- $service
mixed
$service Client configuration array or arbitrary data to register. The client configuration array must include a 'class' (string) and 'params' (array) key.
Returns
Implementation of
Implementation of
Implementation of
Implementation of
Implementation of
Methods inherited from Guzzle\Common\AbstractHasDispatcher
addSubscriber(),
dispatch(),
getEventDispatcher(),
setEventDispatcher()
Magic methods summary
Properties summary
protected
array
|
$builderConfig |
#
Service builder configuration data |
protected
array
|
$clients |
#
Instantiated client objects |
protected static
|
$cachedFactory |
#
Cached instance of the service builder loader |
protected
array
|
$plugins |
#
Plugins to attach to each client created by the service builder |