Plugin manager implementation for translation loaders.

Enforces that loaders retrieved are either instances of Loader\FileLoaderInterface or Loader\RemoteLoaderInterface. Additionally, it registers a number of default loaders.

If you are wanting to use the ability to load translation files from the include_path, you will need to create a factory to override the defaults defined in this class. A simple factory might look like:

function ($translators) {
    $adapter = new Gettext();
    $adapter->setUseIncludePath(true);
    return $adapter;
}

You may need to override the Translator service factory to make this happen more easily. That can be done by extending it:

use Zend\I18n\Translator\TranslatorServiceFactory;
// or Zend\Mvc\I18n\TranslatorServiceFactory
use Zend\ServiceManager\ServiceLocatorInterface;

class MyTranslatorServiceFactory extends TranslatorServiceFactory
{
    public function createService(ServiceLocatorInterface $services)
    {
        $translator = parent::createService($services);
        $translator->getLoaderPluginManager()->setFactory(...);
        return $translator;
    }
}

You would then specify your custom factory in your service configuration.

 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

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

Parameters

$serviceName

string

name of the service being the delegate

$delegatorFactoryName

string

name of the service being the delegator factory

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

Proxies to has()

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 of the requested service

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

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

Parameters

$name

stringarray

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
\Zend\ServiceManager\Exception\ServiceNotCreatedException
\Zend\ServiceManager\Exception\RuntimeException

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() : \Zend\ServiceManager\ServiceLocatorInterface
Inherited

Useful for fetching dependencies from within factories.

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

Returns

Get throw exceptions in create

getThrowExceptionInCreate() : bool
Inherited

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

Returns

bool

Determine if an instance exists.

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

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

Parameters

$alias

string

Returns

bool

isShared()

isShared(string $name) : bool
Inherited

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

Parameters

$name

string

Exceptions

\Zend\ServiceManager\Exception\ServiceNotFoundException

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 an instance of Loader\FileLoaderInterface or Loader\RemoteLoaderInterface.

Parameters

$plugin

mixed

Exceptions

\Zend\I18n\Exception\RuntimeException if invalid

 Properties

                                           

 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