當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。