ServiceManager

Service Manager. Default implementation of the ServiceLocatorInterface, providing capabilities for object creation via: - factories - abstract factories - delegator factories - lazy service factories (generated proxies) - initializers (interface injection) It also provides the ability to inject specific service instances and to define aliases.
implements Interop\Container\ContainerInterface , Psr\Container\ContainerInterface , Zend\ServiceManager\ServiceLocatorInterface

Known subclasses

Omeka\ServiceManager\AbstractPluginManager, Zend\ServiceManager\AbstractPluginManager
Methods Summary
public
# __construct( array $config = array ( ) )
Constructor. See {@see \Zend\ServiceManager\ServiceManager::configure()} for details on what $config accepts.
public
# getServiceLocator( )
Implemented for backwards compatibility with previous plugin managers only. Returns the creation context.

Deprecated


public
# get( $name )
{@inheritDoc}

Implementation of

public
# build( $name , array $options = NULL )
public
# has( $name )
{@inheritDoc}

Implementation of

public
# setAllowOverride( bool $flag )
Indicate whether or not the instance is immutable.
public
# getAllowOverride( )
Retrieve the flag indicating immutability status.
public
# configure( array $config )
Configure the service manager Valid top keys are: - services: service name => service instance pairs - invokables: service name => class name pairs for classes that do not have required constructor arguments; internally, maps the class to an InvokableFactory instance, and creates an alias if the service name and class name do not match. - factories: service name => factory pairs; factories may be any callable, string name resolving to an invokable class, or string name resolving to a FactoryInterface instance. - abstract_factories: an array of abstract factories; these may be instances of AbstractFactoryInterface, or string names resolving to classes that implement that interface. - delegators: service name => list of delegator factories for the given service; each item in the list may be a callable, a string name resolving to an invokable class, or a string name resolving to a class implementing DelegatorFactoryInterface. - shared: service name => flag pairs; the flag is a boolean indicating whether or not the service is shared. - aliases: alias => service name pairs. - lazy_services: lazy service configuration; can contain the keys: - class_map: service name => class name pairs. - proxies_namespace: string namespace to use for generated proxy classes. - proxies_target_dir: directory in which to write generated proxy classes; uses system temporary by default. - write_proxy_files: boolean indicating whether generated proxy classes should be written; defaults to boolean false. - shared_by_default: boolean, indicating if services in this instance should be shared by default.
public
# setAlias( string $alias , string $target )
Add an alias.
public
# setInvokableClass( string $name , null|string $class = NULL )
Add an invokable class mapping.
public
# setFactory( string $name , string|callable|\Factory\FactoryInterface $factory )
Specify a factory for a given service name.
public
# mapLazyService( string $name , null|string $class = NULL )
Create a lazy service mapping to a class.
public
# addAbstractFactory( string|\Factory\AbstractFactoryInterface $factory )
Add an abstract factory for resolving services.
public
# addDelegator( string $name , string|callable|\Factory\DelegatorFactoryInterface $factory )
Add a delegator for a given service.
public
# addInitializer( string|callable|\Initializer\InitializerInterface $initializer )
Add an initializer.
public
# setService( string $name , array|object $service )
Map a service.
public
# setShared( string $name , bool $flag )
Add a service sharing rule.
Properties Summary
protected \Zend\ServiceManager\Factory\AbstractFactoryInterface[] $abstractFactories
# array ( )
protected string[] $aliases
A list of aliases Should map one alias to a service name, or another alias (aliases are recursively resolved)
# array ( )
protected $allowOverride
Whether or not changes may be made to this instance.
# false
protected Interop\Container\ContainerInterface $creationContext
# NULL
protected string[][]|\Zend\ServiceManager\Factory\DelegatorFactoryInterface[][] $delegators
# array ( )
protected string[]|callable[] $factories
A list of factories (either as string name or callable)
# array ( )
protected \Zend\ServiceManager\Initializer\InitializerInterface[] $initializers
# array ( )
protected array $lazyServices
# array ( )
protected array $services
A list of already loaded services (this act as a local cache)
# array ( )
protected bool[] $shared
Enable/disable shared instances by service name. Example configuration: 'shared' => [ MyService::class => true, // will be shared, even if "sharedByDefault" is false MyOtherService::class => false // won't be shared, even if "sharedByDefault" is true ]
# array ( )
protected bool $sharedByDefault
Should the services be shared by default?
# true
protected bool $configured
Service manager was already configured?
# false