Plugin manager implementation for routes

Enforces that routes retrieved are instances of RouteInterface. It overrides createFromInvokable() to call the route's factory method in order to get an instance. The manager is marked to not share by default, in order to allow multiple route instances of the same type.

category Zend
package Zend_Mvc
subpackage Router

 Methods

Constructor

__construct(\Zend\ServiceManager\ConfigInterface $configuration) 
Inherited

Add a default initializer to ensure the plugin is valid after instance creation.

inherited_from \Zend\ServiceManager\AbstractPluginManager::__construct()

Parameters

Add abstract factory

addAbstractFactory(\Zend\ServiceManager\AbstractFactoryInterface | string $factory, bool $topOfStack) : \Zend\ServiceManager\ServiceManager
Inherited

inherited_from \Zend\ServiceManager\ServiceManager::addAbstractFactory()
inherited_from \Zend\ServiceManager\AbstractPluginManager::addAbstractFactory()

Parameters

$topOfStack

bool

Exceptions

\Zend\ServiceManager\Exception\InvalidArgumentException if the abstract factory is invalid

Returns

Add initializer

addInitializer(\Zend\ServiceManager\callable | \Zend\ServiceManager\InitializerInterface $initializer, bool $topOfStack) : \Zend\ServiceManager\ServiceManager
Inherited

inherited_from \Zend\ServiceManager\ServiceManager::addInitializer()
inherited_from \Zend\ServiceManager\AbstractPluginManager::addInitializer()

Parameters

$initializer

\Zend\ServiceManager\callable\Zend\ServiceManager\InitializerInterface

$topOfStack

bool

Exceptions

\Zend\ServiceManager\Exception\InvalidArgumentException

Returns

Add a peering relationship

addPeeringServiceManager(\Zend\ServiceManager\ServiceManager $manager, string $peering) : \Zend\ServiceManager\ServiceManager
Inherited

inherited_from \Zend\ServiceManager\ServiceManager::addPeeringServiceManager()
inherited_from \Zend\ServiceManager\AbstractPluginManager::addPeeringServiceManager()

Parameters

$peering

string

Returns

Determine if we can create an instance.

canCreate(string | array $name, bool $checkAbstractFactories) : bool
Inherited

inherited_from \Zend\ServiceManager\ServiceManager::canCreate()
inherited_from \Zend\ServiceManager\AbstractPluginManager::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()
inherited_from \Zend\ServiceManager\AbstractPluginManager::canCreateFromAbstractFactory()

Parameters

$cName

string

$rName

string

Returns

bool

Create an instance

create(string | array $name) : bool | object
Inherited

inherited_from \Zend\ServiceManager\ServiceManager::create()
inherited_from \Zend\ServiceManager\AbstractPluginManager::create()

Parameters

$name

stringarray

Exceptions

\Zend\ServiceManager\Exception\ServiceNotFoundException
\Zend\ServiceManager\Exception\ServiceNotCreatedException

Returns

boolobject

Create scoped service manager

createScopedServiceManager(string $peering) : \Zend\ServiceManager\ServiceManager
Inherited

inherited_from \Zend\ServiceManager\ServiceManager::createScopedServiceManager()
inherited_from \Zend\ServiceManager\AbstractPluginManager::createScopedServiceManager()

Parameters

$peering

string

Returns

Retrieve a service from the manager by name

get(string $name, array $options, bool $usePeeringServiceManagers) : object
Inherited

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.

inherited_from \Zend\ServiceManager\AbstractPluginManager::get()

Parameters

$name

string

$options

array

$usePeeringServiceManagers

bool

Exceptions

\Zend\ServiceManager\Exception\ServiceNotFoundException

Returns

object

Get allow override

getAllowOverride() : bool
Inherited

inherited_from \Zend\ServiceManager\ServiceManager::getAllowOverride()
inherited_from \Zend\ServiceManager\AbstractPluginManager::getAllowOverride()

Returns

bool

Retrieve a keyed list of all canonical names.

getCanonicalNames() : array
Inherited

Handy for debugging!

inherited_from \Zend\ServiceManager\ServiceManager::getCanonicalNames()
inherited_from \Zend\ServiceManager\AbstractPluginManager::getCanonicalNames()

Returns

array

Retrieve a keyed list of all registered services.

getRegisteredServices() : array
Inherited

Handy for debugging!

inherited_from \Zend\ServiceManager\ServiceManager::getRegisteredServices()
inherited_from \Zend\ServiceManager\AbstractPluginManager::getRegisteredServices()

Returns

array

Get the main plugin manager.

getServiceLocator() : mixed
Inherited

Useful for fetching dependencies from within factories.

inherited_from \Zend\ServiceManager\AbstractPluginManager::getServiceLocator()

Returns

mixed

Get throw exceptions in create

getThrowExceptionInCreate() : bool
Inherited

inherited_from \Zend\ServiceManager\ServiceManager::getThrowExceptionInCreate()
inherited_from \Zend\ServiceManager\AbstractPluginManager::getThrowExceptionInCreate()

Returns

bool

Check for a registered instance

has(string | array $name, bool $checkAbstractFactories, bool $usePeeringServiceManagers) : bool
Inherited

inherited_from \Zend\ServiceManager\ServiceManager::has()
inherited_from \Zend\ServiceManager\AbstractPluginManager::has()

Parameters

$name

stringarray

$checkAbstractFactories

bool

$usePeeringServiceManagers

bool

Returns

bool

Determine if we have an alias

hasAlias(string $alias) : bool
Inherited

inherited_from \Zend\ServiceManager\ServiceManager::hasAlias()
inherited_from \Zend\ServiceManager\AbstractPluginManager::hasAlias()

Parameters

$alias

string

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()
inherited_from \Zend\ServiceManager\AbstractPluginManager::retrieveFromPeeringManagerFirst()

Returns

bool

setAlias()

setAlias(string $alias, string $nameOrAlias) : \Zend\ServiceManager\ServiceManager
Inherited

inherited_from \Zend\ServiceManager\ServiceManager::setAlias()
inherited_from \Zend\ServiceManager\AbstractPluginManager::setAlias()

Parameters

$alias

string

$nameOrAlias

string

Exceptions

\Zend\ServiceManager\Exception\ServiceNotFoundException
\Zend\ServiceManager\Exception\InvalidServiceNameException

Returns

Set allow override

setAllowOverride($allowOverride) : \Zend\ServiceManager\ServiceManager
Inherited

inherited_from \Zend\ServiceManager\ServiceManager::setAllowOverride()
inherited_from \Zend\ServiceManager\AbstractPluginManager::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()
inherited_from \Zend\ServiceManager\AbstractPluginManager::setCanonicalNames()

Parameters

$canonicalNames

array

Returns

Set factory

setFactory(string $name, string | \Zend\ServiceManager\FactoryInterface | \Zend\ServiceManager\callable $factory, bool $shared) : \Zend\ServiceManager\ServiceManager
Inherited

inherited_from \Zend\ServiceManager\ServiceManager::setFactory()
inherited_from \Zend\ServiceManager\AbstractPluginManager::setFactory()

Parameters

$name

string

$factory

string\Zend\ServiceManager\FactoryInterface\Zend\ServiceManager\callable

$shared

bool

Exceptions

\Zend\ServiceManager\Exception\InvalidArgumentException
\Zend\ServiceManager\Exception\InvalidServiceNameException

Returns

Set invokable class

setInvokableClass(string $name, string $invokableClass, bool $shared) : \Zend\ServiceManager\ServiceManager
Inherited

inherited_from \Zend\ServiceManager\ServiceManager::setInvokableClass()
inherited_from \Zend\ServiceManager\AbstractPluginManager::setInvokableClass()

Parameters

$name

string

$invokableClass

string

$shared

bool

Exceptions

\Zend\ServiceManager\Exception\InvalidServiceNameException

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()
inherited_from \Zend\ServiceManager\AbstractPluginManager::setRetrieveFromPeeringManagerFirst()

Parameters

$retrieveFromPeeringManagerFirst

bool

Returns

Register a service with the locator.

setService(string $name, mixed $service, bool $shared) : \Zend\ServiceManager\AbstractPluginManager
Inherited

Validates that the service object via validatePlugin() prior to attempting to register it.

inherited_from \Zend\ServiceManager\AbstractPluginManager::setService()

Parameters

$name

string

$service

mixed

$shared

bool

Exceptions

\Zend\ServiceManager\Exception\InvalidServiceNameException

Returns

Set the main service locator so factories can have access to it to pull deps

setServiceLocator(\Zend\ServiceManager\ServiceLocatorInterface $serviceLocator) : \Zend\ServiceManager\AbstractPluginManager
Inherited

inherited_from \Zend\ServiceManager\AbstractPluginManager::setServiceLocator()

Parameters

Returns

Set flag indicating whether services are shared by default

setShareByDefault(bool $shareByDefault) : \Zend\ServiceManager\ServiceManager
Inherited

inherited_from \Zend\ServiceManager\ServiceManager::setShareByDefault()
inherited_from \Zend\ServiceManager\AbstractPluginManager::setShareByDefault()

Parameters

$shareByDefault

bool

Exceptions

\Zend\ServiceManager\Exception\RuntimeException if allowOverride is false

Returns

setShared()

setShared(string $name, bool $isShared) : \Zend\ServiceManager\ServiceManager
Inherited

inherited_from \Zend\ServiceManager\ServiceManager::setShared()
inherited_from \Zend\ServiceManager\AbstractPluginManager::setShared()

Parameters

$name

string

$isShared

bool

Exceptions

\Zend\ServiceManager\Exception\ServiceNotFoundException

Returns

Set throw exceptions in create

setThrowExceptionInCreate(bool $throwExceptionInCreate) : \Zend\ServiceManager\ServiceManager
Inherited

inherited_from \Zend\ServiceManager\ServiceManager::setThrowExceptionInCreate()
inherited_from \Zend\ServiceManager\AbstractPluginManager::setThrowExceptionInCreate()

Parameters

$throwExceptionInCreate

bool

Returns

Are services shared by default?

shareByDefault() : bool
Inherited

inherited_from \Zend\ServiceManager\ServiceManager::shareByDefault()
inherited_from \Zend\ServiceManager\AbstractPluginManager::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

\Zend\Mvc\Router\Exception\RuntimeException if invalid

Canonicalize name

canonicalizeName(string $name) : string
Inherited

inherited_from \Zend\ServiceManager\ServiceManager::canonicalizeName()
inherited_from \Zend\ServiceManager\AbstractPluginManager::canonicalizeName()

Parameters

$name

string

Returns

string

Attempt to create an instance via an abstract factory

createFromAbstractFactory(string $canonicalName, string $requestedName) : object | null
Inherited

inherited_from \Zend\ServiceManager\ServiceManager::createFromAbstractFactory()
inherited_from \Zend\ServiceManager\AbstractPluginManager::createFromAbstractFactory()

Parameters

$canonicalName

string

$requestedName

string

Exceptions

\Zend\ServiceManager\Exception\ServiceNotCreatedException If abstract factory is not callable

Returns

objectnull

Attempt to create an instance via a factory class

createFromFactory(string $canonicalName, string $requestedName) : mixed
Inherited

Overrides parent implementation by passing $creationOptions to the constructor, if non-null.

inherited_from \Zend\ServiceManager\AbstractPluginManager::createFromFactory()

Parameters

$canonicalName

string

$requestedName

string

Exceptions

\Zend\ServiceManager\Exception\ServiceNotCreatedException If factory is not callable

Returns

mixed

Attempt to create an instance via an invokable class

createFromInvokable(string $canonicalName, string $requestedName) : null | \stdClass

Overrides parent implementation by invoking the route factory, passing $creationOptions as the argument.

Parameters

$canonicalName

string

$requestedName

string

Exceptions

\Zend\Mvc\Router\Exception\RuntimeException If resolved class does not exist, or does not implement RouteInterface

Returns

null\stdClass

Create service via callback

createServiceViaCallback(\Zend\ServiceManager\callable $callable, string $cName, string $rName) : object
Inherited

inherited_from \Zend\ServiceManager\ServiceManager::createServiceViaCallback()
inherited_from \Zend\ServiceManager\AbstractPluginManager::createServiceViaCallback()

Parameters

$callable

\Zend\ServiceManager\callable

$cName

string

$rName

string

Exceptions

\Zend\ServiceManager\Exception\ServiceNotCreatedException
\Zend\ServiceManager\Exception\ServiceNotFoundException
\Zend\ServiceManager\Exception\CircularDependencyFoundException

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()
inherited_from \Zend\ServiceManager\AbstractPluginManager::isSubclassOf()

Parameters

$className

string

$type

string

Returns

bool

Attempt to retrieve an instance via a peering manager

retrieveFromPeeringManager(string $name) : mixed
Inherited

inherited_from \Zend\ServiceManager\ServiceManager::retrieveFromPeeringManager()
inherited_from \Zend\ServiceManager\AbstractPluginManager::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()
inherited_from \Zend\ServiceManager\AbstractPluginManager::unregisterService()

Parameters

$canonical

string

 Properties

 

$abstractFactories

$abstractFactories : \Zend\ServiceManager\AbstractFactoryInterface[]
Inherited

inherited_from \Zend\ServiceManager\ServiceManager::$$abstractFactories
inherited_from \Zend\ServiceManager\AbstractPluginManager::$$abstractFactories
 

$aliases

$aliases : array
Inherited

inherited_from \Zend\ServiceManager\ServiceManager::$$aliases
inherited_from \Zend\ServiceManager\AbstractPluginManager::$$aliases
 

Allow overriding by default

$allowOverride : bool
Inherited

inherited_from \Zend\ServiceManager\AbstractPluginManager::$$allowOverride
 

Whether or not to auto-add a class as an invokable class if it exists

$autoAddInvokableClass : bool
Inherited

inherited_from \Zend\ServiceManager\AbstractPluginManager::$$autoAddInvokableClass
 

Lookup for canonicalized names.

$canonicalNames : array
Inherited

inherited_from \Zend\ServiceManager\ServiceManager::$$canonicalNames
inherited_from \Zend\ServiceManager\AbstractPluginManager::$$canonicalNames
 

<p>map of characters to be replaced through strtr</p>

$canonicalNamesReplacements : array
Inherited

inherited_from \Zend\ServiceManager\ServiceManager::$$canonicalNamesReplacements
inherited_from \Zend\ServiceManager\AbstractPluginManager::$$canonicalNamesReplacements
 

Options to use when creating an instance

$creationOptions : mixed
Inherited

inherited_from \Zend\ServiceManager\AbstractPluginManager::$$creationOptions
 

$factories

$factories : string | \Zend\ServiceManager\callable | \Closure | \Zend\ServiceManager\FactoryInterface[]
Inherited

inherited_from \Zend\ServiceManager\ServiceManager::$$factories
inherited_from \Zend\ServiceManager\AbstractPluginManager::$$factories
 

$initializers

$initializers : array
Inherited

inherited_from \Zend\ServiceManager\ServiceManager::$$initializers
inherited_from \Zend\ServiceManager\AbstractPluginManager::$$initializers
 

Registered services and cached values

$instances : array
Inherited

inherited_from \Zend\ServiceManager\ServiceManager::$$instances
inherited_from \Zend\ServiceManager\AbstractPluginManager::$$instances
 

$invokableClasses

$invokableClasses : array
Inherited

inherited_from \Zend\ServiceManager\ServiceManager::$$invokableClasses
inherited_from \Zend\ServiceManager\AbstractPluginManager::$$invokableClasses
 

$peeringServiceManagers

$peeringServiceManagers : \Zend\ServiceManager\ServiceManager[]
Inherited

inherited_from \Zend\ServiceManager\ServiceManager::$$peeringServiceManagers
inherited_from \Zend\ServiceManager\AbstractPluginManager::$$peeringServiceManagers
 

$pendingAbstractFactoryRequests

$pendingAbstractFactoryRequests : array
Inherited

inherited_from \Zend\ServiceManager\ServiceManager::$$pendingAbstractFactoryRequests
inherited_from \Zend\ServiceManager\AbstractPluginManager::$$pendingAbstractFactoryRequests
 

$retrieveFromPeeringManagerFirst

$retrieveFromPeeringManagerFirst : bool
Inherited

inherited_from \Zend\ServiceManager\ServiceManager::$$retrieveFromPeeringManagerFirst
inherited_from \Zend\ServiceManager\AbstractPluginManager::$$retrieveFromPeeringManagerFirst
 

The main service locator

$serviceLocator : \Zend\ServiceManager\ServiceLocatorInterface
Inherited

inherited_from \Zend\ServiceManager\AbstractPluginManager::$$serviceLocator
 

Whether or not to share by default

$shareByDefault : bool

 

$shared

$shared : array
Inherited

inherited_from \Zend\ServiceManager\ServiceManager::$$shared
inherited_from \Zend\ServiceManager\AbstractPluginManager::$$shared
 

<p>Track whether not to throw exceptions during create()</p>

$throwExceptionInCreate : bool
Inherited

inherited_from \Zend\ServiceManager\ServiceManager::$$throwExceptionInCreate
inherited_from \Zend\ServiceManager\AbstractPluginManager::$$throwExceptionInCreate

 Constants

 

SCOPE_CHILD

SCOPE_CHILD 
Inherited

inherited_from \Zend\ServiceManager\ServiceManager::SCOPE_CHILD
inherited_from \Zend\ServiceManager\AbstractPluginManager::SCOPE_CHILD
 

SCOPE_PARENT

SCOPE_PARENT 
Inherited

inherited_from \Zend\ServiceManager\ServiceManager::SCOPE_PARENT
inherited_from \Zend\ServiceManager\AbstractPluginManager::SCOPE_PARENT