本文整理汇总了PHP中Zend\I18n\Translator\Translator::factory方法的典型用法代码示例。如果您正苦于以下问题:PHP Translator::factory方法的具体用法?PHP Translator::factory怎么用?PHP Translator::factory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\I18n\Translator\Translator
的用法示例。
在下文中一共展示了Translator::factory方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
public function setUp()
{
$command = new GenerateCharsetCommand(Translator::factory([]));
$app = new Application();
$app->add($command);
$this->commandTester = new CommandTester($command);
}
示例2: createService
/**
* @param ServiceLocatorInterface $serviceLocator
* @return MvcTranslator
*/
public function createService(ServiceLocatorInterface $serviceLocator)
{
// Assume that if a user has registered a service for the
// TranslatorInterface, it must be valid
if ($serviceLocator->has('Zend\\I18n\\Translator\\TranslatorInterface')) {
return new MvcTranslator($serviceLocator->get('Zend\\I18n\\Translator\\TranslatorInterface'));
}
// If ext/intl is not loaded, return a dummy translator
if (!extension_loaded('intl')) {
return new MvcTranslator(new DummyTranslator());
}
// Load a translator from configuration, if possible
if ($serviceLocator->has('Config')) {
$config = $serviceLocator->get('Config');
// 'translator' => false
if (array_key_exists('translator', $config) && $config['translator'] === false) {
return new MvcTranslator(new DummyTranslator());
}
// 'translator' => array( ... translator options ... )
if (array_key_exists('translator', $config) && (is_array($config['translator']) && !empty($config['translator']) || $config['translator'] instanceof Traversable)) {
$i18nTranslator = Translator::factory($config['translator']);
$serviceLocator->setService('Zend\\I18n\\Translator\\TranslatorInterface', $i18nTranslator);
return new MvcTranslator($i18nTranslator);
}
}
// For BC purposes (pre-2.3.0), use the I18n Translator
return new MvcTranslator(new Translator());
}
示例3: setUp
public function setUp()
{
$this->apiKeyService = $this->prophesize(ApiKeyService::class);
$command = new ListKeysCommand($this->apiKeyService->reveal(), Translator::factory([]));
$app = new Application();
$app->add($command);
$this->commandTester = new CommandTester($command);
}
示例4: setUp
public function setUp()
{
$this->visitsTracker = $this->prophesize(VisitsTrackerInterface::class);
$command = new GetVisitsCommand($this->visitsTracker->reveal(), Translator::factory([]));
$app = new Application();
$app->add($command);
$this->commandTester = new CommandTester($command);
}
示例5: setUp
public function setUp()
{
$this->urlShortener = $this->prophesize(UrlShortener::class);
$command = new ResolveUrlCommand($this->urlShortener->reveal(), Translator::factory([]));
$app = new Application();
$app->add($command);
$this->commandTester = new CommandTester($command);
}
示例6: testInvoke
public function testInvoke()
{
$sm = new ServiceManager();
$sm->setService(Translator::class, Translator::factory([]));
$sm->setService(RouterInterface::class, $this->prophesize(RouterInterface::class)->reveal());
$instance = $this->factory->__invoke($sm);
$this->assertInstanceOf(LanguageMiddleware::class, $instance);
}
示例7: __invoke
/**
* Create a Translator instance.
*
* @param ContainerInterface $container
* @param string $requestedName
* @param null|array $options
* @return Translator
*/
public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
{
// Configure the translator
$config = $container->get('config');
$trConfig = isset($config['translator']) ? $config['translator'] : [];
$translator = Translator::factory($trConfig);
return $translator;
}
示例8: setUp
public function setUp()
{
$this->urlShortener = $this->prophesize(UrlShortener::class);
$command = new GenerateShortcodeCommand($this->urlShortener->reveal(), Translator::factory([]), ['schema' => 'http', 'hostname' => 'foo.com']);
$app = new Application();
$app->add($command);
$this->commandTester = new CommandTester($command);
}
示例9: createService
public function createService(ServiceLocatorInterface $serviceLocator)
{
// Configure the translator
$config = $serviceLocator->get('Configuration');
$trConfig = isset($config['translator']) ? $config['translator'] : array();
$translator = Translator::factory($trConfig);
return $translator;
}
示例10: setUp
public function setUp()
{
$this->factory = new RendererFactory();
$this->container = $this->prophesize(ContainerInterface::class);
$this->container->get('translator')->willReturn(Translator::factory([]));
$this->container->get('config')->willReturn(['navigation' => [], 'recaptcha' => []]);
$this->container->get(RouteAssembler::class)->willReturn($this->prophesize(RouteAssembler::class)->reveal());
}
示例11: setUp
public function setUp()
{
$this->visitService = $this->prophesize(VisitService::class);
$this->ipResolver = $this->prophesize(IpLocationResolver::class);
$command = new ProcessVisitsCommand($this->visitService->reveal(), $this->ipResolver->reveal(), Translator::factory([]));
$app = new Application();
$app->add($command);
$this->commandTester = new CommandTester($command);
}
示例12: setUp
public function setUp()
{
$routeAssemblerProphezy = $this->prophesize(RouteAssembler::class);
$routeAssemblerProphezy->assembleUrl('home', true)->willReturn('/foo/bar');
$routeAssemblerProphezy->assembleUrl(null, ['lang' => 'es'])->willReturn('/es');
$routeAssemblerProphezy->assembleUrl(null, ['lang' => 'en'])->willReturn('/en');
$routeAssemblerProphezy->getCurrentRouteResult()->willReturn(RouteResult::fromRouteMatch('home', 'HelloWorld', []));
$this->extension = new NavigationExtension(Translator::factory([]), $routeAssemblerProphezy->reveal(), ['menu' => [['route' => 'home', 'icon' => 'house', 'label' => 'Home'], ['uri' => 'http://foo.com', 'target' => true, 'label' => 'Blog', 'icon' => 'book']], 'lang_menu' => [['label' => 'Español', 'class' => 'es', 'params' => ['lang' => 'es']], ['label' => 'English', 'class' => 'en', 'params' => ['lang' => 'en']]]]);
}
示例13: setUp
public function setUp()
{
$this->shortUrlService = $this->prophesize(ShortUrlServiceInterface::class);
$app = new Application();
$command = new ListShortcodesCommand($this->shortUrlService->reveal(), Translator::factory([]));
$app->add($command);
$this->questionHelper = $command->getHelper('question');
$this->commandTester = new CommandTester($command);
}
示例14: setUp
public function setUp()
{
$this->request = new ServerRequest();
$router = $this->prophesize(RouterInterface::class);
$router->match($this->request)->willReturn(RouteResult::fromRouteMatch('home', function ($req, $resp) {
return $resp;
}, ['lang' => 'es']));
$this->translator = Translator::factory(['locale' => 'en']);
$this->middleware = new LanguageMiddleware($this->translator, $router->reveal());
}
示例15: setUp
public function setUp()
{
$this->module = new Module();
$this->app = $this->getMockBuilder('Zend\\Mvc\\Application')->disableOriginalConstructor()->getMock();
$sm = new ServiceManager(new Config(['services' => ['translator' => Translator::factory(['locale' => 'id_ID'])]]));
$this->app->expects($this->any())->method('getServiceManager')->willReturn($sm);
$em = new EventManager();
$em->setSharedManager(new SharedEventManager());
$this->app->expects($this->any())->method('getEventManager')->willReturn($em);
}