3 * Zend Framework (http://framework.zend.com/)
5 * @link http://github.com/zendframework/zf2 for the canonical source repository
6 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
7 * @license http://framework.zend.com/license/new-bsd New BSD License
10 namespace Zend\I18n\Translator
;
12 use Interop\Container\ContainerInterface
;
13 use Zend\ServiceManager\FactoryInterface
;
14 use Zend\ServiceManager\ServiceLocatorInterface
;
19 class TranslatorServiceFactory
implements FactoryInterface
22 * Create a Translator instance.
24 * @param ContainerInterface $container
25 * @param string $requestedName
26 * @param null|array $options
29 public function __invoke(ContainerInterface
$container, $requestedName, array $options = null)
31 // Configure the translator
32 $config = $container->get('config');
33 $trConfig = isset($config['translator']) ?
$config['translator'] : [];
34 $translator = Translator
::factory($trConfig);
35 if ($container->has('TranslatorPluginManager')) {
36 $translator->setPluginManager($container->get('TranslatorPluginManager'));
42 * zend-servicemanager v2 factory for creating Translator instance.
44 * Proxies to `__invoke()`.
46 * @param ServiceLocatorInterface $serviceLocator
49 public function createService(ServiceLocatorInterface
$serviceLocator)
51 return $this($serviceLocator, Translator
::class);