Automatically registers an initializer which should be used to verify that
a plugin instance is of a valid type. Additionally, allows plugins to accept
an array of options for the constructor, which can be used to configure
the plugin when retrieved. Finally, enables the allowOverride property by
default to allow registering factories, aliases, and invokables to take
the place of those provided by the implementing class.
Methods
Constructor
__construct(\Zend\ServiceManager\ConfigInterface $configuration)
Add a default initializer to ensure the plugin is valid after instance
creation.
Parameters
Sets the given service name as to be handled by a delegator factory
addDelegator(string $serviceName, string $delegatorFactoryName) : \Zend\ServiceManager\ServiceManager
Inherited
| inherited_from |
\Zend\ServiceManager\ServiceManager::addDelegator() |
Parameters
$serviceName
stringname of the service being the delegate
$delegatorFactoryName
stringname of the service being the delegator factory
Returns
Add a peering relationship
addPeeringServiceManager(\Zend\ServiceManager\ServiceManager $manager, string $peering) : \Zend\ServiceManager\ServiceManager
Inherited
| inherited_from |
\Zend\ServiceManager\ServiceManager::addPeeringServiceManager() |
Parameters
$peering
string
Returns
Determine if we can create an instance.
canCreate(string | array $name, bool $checkAbstractFactories) : bool
Inherited
Proxies to has()
| inherited_from |
\Zend\ServiceManager\ServiceManager::canCreate() |
Parameters
$name
stringarray
$checkAbstractFactories
bool
Returns
bool
Determine if we can create an instance from an abstract factory.
canCreateFromAbstractFactory(string $cName, string $rName) : bool
Inherited
| inherited_from |
\Zend\ServiceManager\ServiceManager::canCreateFromAbstractFactory() |
Parameters
$cName
string
$rName
string
Returns
bool
Create an instance of the requested service
create(string | array $name) : bool | object
Inherited
| inherited_from |
\Zend\ServiceManager\ServiceManager::create() |
Parameters
$name
stringarray
Returns
boolobject
Create scoped service manager
createScopedServiceManager(string $peering) : \Zend\ServiceManager\ServiceManager
Inherited
| inherited_from |
\Zend\ServiceManager\ServiceManager::createScopedServiceManager() |
Parameters
$peering
string
Returns
Retrieve a service from the manager by name
get(string $name, array $options, bool $usePeeringServiceManagers) : object
Allows passing an array of options to use when creating the instance.
createFromInvokable() will use these and pass them to the instance
constructor if not null and a non-empty array.
Parameters
$name
string
$options
array
$usePeeringServiceManagers
bool
Exceptions
Returns
object
Get allow override
getAllowOverride() : bool
Inherited
| inherited_from |
\Zend\ServiceManager\ServiceManager::getAllowOverride() |
Returns
bool
Retrieve a keyed list of all canonical names.
getCanonicalNames() : array
Inherited
Handy for debugging!
| inherited_from |
\Zend\ServiceManager\ServiceManager::getCanonicalNames() |
Returns
array
Retrieve a keyed list of all registered services.
getRegisteredServices() : array
Inherited
Handy for debugging!
| inherited_from |
\Zend\ServiceManager\ServiceManager::getRegisteredServices() |
Returns
array
Get throw exceptions in create
getThrowExceptionInCreate() : bool
Inherited
| inherited_from |
\Zend\ServiceManager\ServiceManager::getThrowExceptionInCreate() |
Returns
bool
Determine if an instance exists.
has(string | array $name, bool $checkAbstractFactories, bool $usePeeringServiceManagers) : bool
Inherited
| inherited_from |
\Zend\ServiceManager\ServiceManager::has() |
Parameters
$name
stringarrayAn array argument accepts exactly two values. Example: array('canonicalName', 'requestName')
$checkAbstractFactories
bool
$usePeeringServiceManagers
bool
Returns
bool
Determine if we have an alias
hasAlias(string $alias) : bool
Inherited
| inherited_from |
\Zend\ServiceManager\ServiceManager::hasAlias() |
Parameters
$alias
string
Returns
bool
isShared()
isShared(string $name) : bool
Inherited
| inherited_from |
\Zend\ServiceManager\ServiceManager::isShared() |
Parameters
$name
string
Exceptions
Returns
bool
Should we retrieve from the peering manager prior to attempting to create a service?
retrieveFromPeeringManagerFirst() : bool
Inherited
| inherited_from |
\Zend\ServiceManager\ServiceManager::retrieveFromPeeringManagerFirst() |
Returns
bool
setAlias()
setAlias(string $alias, string $nameOrAlias) : \Zend\ServiceManager\ServiceManager
Inherited
| inherited_from |
\Zend\ServiceManager\ServiceManager::setAlias() |
Parameters
$alias
string
$nameOrAlias
string
Exceptions
Returns
Set allow override
setAllowOverride($allowOverride) : \Zend\ServiceManager\ServiceManager
Inherited
| inherited_from |
\Zend\ServiceManager\ServiceManager::setAllowOverride() |
Parameters
$allowOverride
Returns
Allows to override the canonical names lookup map with predefined
values.
setCanonicalNames(array $canonicalNames) : \Zend\ServiceManager\ServiceManager
Inherited
| inherited_from |
\Zend\ServiceManager\ServiceManager::setCanonicalNames() |
Parameters
$canonicalNames
array
Returns
Set invokable class
setInvokableClass(string $name, string $invokableClass, bool $shared) : \Zend\ServiceManager\ServiceManager
Inherited
| inherited_from |
\Zend\ServiceManager\ServiceManager::setInvokableClass() |
Parameters
$name
string
$invokableClass
string
$shared
bool
Exceptions
Returns
Set flag indicating whether to pull from peering manager before attempting creation
setRetrieveFromPeeringManagerFirst(bool $retrieveFromPeeringManagerFirst) : \Zend\ServiceManager\ServiceManager
Inherited
| inherited_from |
\Zend\ServiceManager\ServiceManager::setRetrieveFromPeeringManagerFirst() |
Parameters
$retrieveFromPeeringManagerFirst
bool
Returns
Register a service with the locator.
setService(string $name, mixed $service, bool $shared) : \Zend\ServiceManager\AbstractPluginManager
Validates that the service object via validatePlugin() prior to
attempting to register it.
Parameters
$name
string
$service
mixed
$shared
bool
Exceptions
Returns
Set flag indicating whether services are shared by default
setShareByDefault(bool $shareByDefault) : \Zend\ServiceManager\ServiceManager
Inherited
| inherited_from |
\Zend\ServiceManager\ServiceManager::setShareByDefault() |
Parameters
$shareByDefault
bool
Exceptions
Returns
setShared()
setShared(string $name, bool $isShared) : \Zend\ServiceManager\ServiceManager
Inherited
| inherited_from |
\Zend\ServiceManager\ServiceManager::setShared() |
Parameters
$name
string
$isShared
bool
Exceptions
Returns
Set throw exceptions in create
setThrowExceptionInCreate(bool $throwExceptionInCreate) : \Zend\ServiceManager\ServiceManager
Inherited
| inherited_from |
\Zend\ServiceManager\ServiceManager::setThrowExceptionInCreate() |
Parameters
$throwExceptionInCreate
bool
Returns
Are services shared by default?
shareByDefault() : bool
Inherited
| inherited_from |
\Zend\ServiceManager\ServiceManager::shareByDefault() |
Returns
bool
Validate the plugin
validatePlugin(mixed $plugin) : void
Checks that the filter loaded is either a valid callback or an instance
of FilterInterface.
Parameters
$plugin
mixed
Exceptions
Canonicalize name
canonicalizeName(string $name) : string
Inherited
| inherited_from |
\Zend\ServiceManager\ServiceManager::canonicalizeName() |
Parameters
$name
string
Returns
string
Ensure the alias definition will not result in a circular reference
checkForCircularAliasReference(string $alias, string $nameOrAlias) : \Zend\ServiceManager\self
Inherited
| inherited_from |
\Zend\ServiceManager\ServiceManager::checkForCircularAliasReference() |
Parameters
$alias
string
$nameOrAlias
string
Exceptions
Returns
\Zend\ServiceManager\self
checkNestedContextStart()
checkNestedContextStart(string $cName) : \Zend\ServiceManager\self
Inherited
| inherited_from |
\Zend\ServiceManager\ServiceManager::checkNestedContextStart() |
Parameters
$cName
string
Returns
\Zend\ServiceManager\self
checkNestedContextStop()
checkNestedContextStop(bool $force) : \Zend\ServiceManager\self
Inherited
| inherited_from |
\Zend\ServiceManager\ServiceManager::checkNestedContextStop() |
Parameters
$force
bool
Returns
\Zend\ServiceManager\self
createDelegatorFromFactory()
createDelegatorFromFactory($canonicalName, $requestedName) : mixed
Inherited
| inherited_from |
\Zend\ServiceManager\ServiceManager::createDelegatorFromFactory() |
Parameters
$canonicalName
$requestedName
Exceptions
Returns
mixed
Attempt to create an instance via an abstract factory
createFromAbstractFactory(string $canonicalName, string $requestedName) : object | null
Inherited
| inherited_from |
\Zend\ServiceManager\ServiceManager::createFromAbstractFactory() |
Parameters
$canonicalName
string
$requestedName
string
Exceptions
Returns
objectnull
Attempt to create an instance via a factory class
createFromFactory(string $canonicalName, string $requestedName) : mixed
Overrides parent implementation by passing $creationOptions to the
constructor, if non-null.
Parameters
$canonicalName
string
$requestedName
string
Exceptions
Returns
mixed
Attempt to create an instance via an invokable class
createFromInvokable(string $canonicalName, string $requestedName) : null | \stdClass
Overrides parent implementation by passing $creationOptions to the
constructor, if non-null.
Parameters
$canonicalName
string
$requestedName
string
Exceptions
Returns
Create service via callback
createServiceViaCallback(\Zend\ServiceManager\callable $callable, string $cName, string $rName) : object
Parameters
$callable
\Zend\ServiceManager\callable
$cName
string
$rName
string
Exceptions
Returns
object
Checks if the object has this class as one of its parents
isSubclassOf(string $className, string $type) : bool
Inherited
| see |
\Zend\ServiceManager\https://bugs.php.net/bug.php?id=53727 |
| see |
\Zend\ServiceManager\https://github.com/zendframework/zf2/pull/1807 |
| inherited_from |
\Zend\ServiceManager\ServiceManager::isSubclassOf() |
Parameters
$className
string
$type
string
Returns
bool
Loop over peering service managers.
loopPeeringServiceManagers(string $name) : mixed
Inherited
| inherited_from |
\Zend\ServiceManager\ServiceManager::loopPeeringServiceManagers() |
Parameters
$name
string
Returns
mixed
Resolve the alias for the given canonical name
resolveAlias(string $cName) : string
Inherited
| inherited_from |
\Zend\ServiceManager\ServiceManager::resolveAlias() |
Parameters
$cName
stringThe canonical name to resolve
Returns
stringThe resolved canonical name
Attempt to retrieve an instance via a peering manager
retrieveFromPeeringManager(string $name) : mixed
Inherited
| inherited_from |
\Zend\ServiceManager\ServiceManager::retrieveFromPeeringManager() |
Parameters
$name
string
Returns
mixed
Unregister a service
unregisterService(string $canonical) : void
Inherited
Called when $allowOverride is true and we detect that a service being
added to the instance already exists. This will remove the duplicate
entry, and also any shared flags previously registered.
| inherited_from |
\Zend\ServiceManager\ServiceManager::unregisterService() |
Parameters
$canonical
string
Creates a callback that uses a delegator to create a service
createDelegatorCallback(\Zend\ServiceManager\DelegatorFactoryInterface | \Zend\ServiceManager\callable $delegatorFactory, string $rName, string $cName, \Zend\ServiceManager\callable $creationCallback) : \Zend\ServiceManager\callable
Inherited
| inherited_from |
\Zend\ServiceManager\ServiceManager::createDelegatorCallback() |
Parameters
$rName
stringrequested service name
$cName
stringcanonical service name
$creationCallback
\Zend\ServiceManager\callablecallback for instantiating the real service
Returns
\Zend\ServiceManager\callable
tryThrowingServiceLocatorUsageException()
tryThrowingServiceLocatorUsageException(string $serviceName, bool $isAutoInvokable, \Exception $exception)
Parameters
$serviceName
string
$isAutoInvokable
bool
Exceptions
Properties
$aliases
$aliases : array
Inherited
| inherited_from |
\Zend\ServiceManager\ServiceManager::$$aliases |
Allow overriding by default
$allowOverride : bool
Whether or not to auto-add a class as an invokable class if it exists
$autoAddInvokableClass : bool
Lookup for canonicalized names.
$canonicalNames : array
Inherited
| inherited_from |
\Zend\ServiceManager\ServiceManager::$$canonicalNames |
<p>map of characters to be replaced through strtr</p>
$canonicalNamesReplacements : array
Inherited
| inherited_from |
\Zend\ServiceManager\ServiceManager::$$canonicalNamesReplacements |
Options to use when creating an instance
$creationOptions : mixed
$delegators
$delegators : array[]
Inherited
| inherited_from |
\Zend\ServiceManager\ServiceManager::$$delegators |
$initializers
$initializers : array
Inherited
| inherited_from |
\Zend\ServiceManager\ServiceManager::$$initializers |
Registered services and cached values
$instances : array
Inherited
| inherited_from |
\Zend\ServiceManager\ServiceManager::$$instances |
$invokableClasses
$invokableClasses : array
Inherited
| inherited_from |
\Zend\ServiceManager\ServiceManager::$$invokableClasses |
$nestedContext
$nestedContext : array
Inherited
| inherited_from |
\Zend\ServiceManager\ServiceManager::$$nestedContext |
$nestedContextCounter
$nestedContextCounter : integer
Inherited
| inherited_from |
\Zend\ServiceManager\ServiceManager::$$nestedContextCounter |
$pendingAbstractFactoryRequests
$pendingAbstractFactoryRequests : array
Inherited
| inherited_from |
\Zend\ServiceManager\ServiceManager::$$pendingAbstractFactoryRequests |
$retrieveFromPeeringManagerFirst
$retrieveFromPeeringManagerFirst : bool
Inherited
| inherited_from |
\Zend\ServiceManager\ServiceManager::$$retrieveFromPeeringManagerFirst |
Whether or not to share by default
$shareByDefault : bool
Inherited
| inherited_from |
\Zend\ServiceManager\ServiceManager::$$shareByDefault |
$shared
$shared : array
Inherited
| inherited_from |
\Zend\ServiceManager\ServiceManager::$$shared |
<p>Track whether not to throw exceptions during create()</p>
$throwExceptionInCreate : bool
Inherited
| inherited_from |
\Zend\ServiceManager\ServiceManager::$$throwExceptionInCreate |
Constants
SCOPE_CHILD
SCOPE_CHILD
Inherited
| inherited_from |
\Zend\ServiceManager\ServiceManager::SCOPE_CHILD |
SCOPE_PARENT
SCOPE_PARENT
Inherited
| inherited_from |
\Zend\ServiceManager\ServiceManager::SCOPE_PARENT |