当前位置: 首页>>代码示例>>PHP>>正文


PHP Translator::factory方法代码示例

本文整理汇总了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);
 }
开发者ID:shlinkio,项目名称:shlink,代码行数:7,代码来源:GenerateCharsetCommandTest.php

示例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());
 }
开发者ID:JeoffScott,项目名称:dyplom,代码行数:32,代码来源:TranslatorServiceFactory.php

示例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);
 }
开发者ID:shlinkio,项目名称:shlink,代码行数:8,代码来源:ListKeysCommandTest.php

示例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);
 }
开发者ID:shlinkio,项目名称:shlink,代码行数:8,代码来源:GetVisitsCommandTest.php

示例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);
 }
开发者ID:shlinkio,项目名称:shlink,代码行数:8,代码来源:ResolveUrlCommandTest.php

示例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);
 }
开发者ID:kukoman,项目名称:website-expressive,代码行数:8,代码来源:LanguageMiddlewareFactoryTest.php

示例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;
 }
开发者ID:axelmdev,项目名称:ecommerce,代码行数:16,代码来源:TranslatorServiceFactory.php

示例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);
 }
开发者ID:shlinkio,项目名称:shlink,代码行数:8,代码来源:GenerateShortcodeCommandTest.php

示例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;
 }
开发者ID:haoyanfei,项目名称:zf2,代码行数:8,代码来源:TranslatorServiceFactory.php

示例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());
 }
开发者ID:kukoman,项目名称:website-expressive,代码行数:8,代码来源:RendererFactoryTest.php

示例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);
 }
开发者ID:shlinkio,项目名称:shlink,代码行数:9,代码来源:ProcessVisitsCommandTest.php

示例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']]]]);
 }
开发者ID:acelaya,项目名称:alejandrocelaya.com,代码行数:9,代码来源:NavigationExtensionTest.php

示例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);
 }
开发者ID:shlinkio,项目名称:shlink,代码行数:9,代码来源:ListShortcodesCommandTest.php

示例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());
 }
开发者ID:kukoman,项目名称:website-expressive,代码行数:10,代码来源:LanguageMiddlewareTest.php

示例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);
 }
开发者ID:jkhaled,项目名称:LearnZF2,代码行数:10,代码来源:ModuleTest.php


注:本文中的Zend\I18n\Translator\Translator::factory方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。