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


PHP HelperPluginManager::setServiceLocator方法代码示例

本文整理汇总了PHP中Zend\View\HelperPluginManager::setServiceLocator方法的典型用法代码示例。如果您正苦于以下问题:PHP HelperPluginManager::setServiceLocator方法的具体用法?PHP HelperPluginManager::setServiceLocator怎么用?PHP HelperPluginManager::setServiceLocator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend\View\HelperPluginManager的用法示例。


在下文中一共展示了HelperPluginManager::setServiceLocator方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testCreateService

 public function testCreateService()
 {
     $helperPluginManager = new HelperPluginManager();
     $helperPluginManager->setServiceLocator(Bootstrap::getServiceManager());
     $result = $this->testedObj->createService($helperPluginManager);
     $this->assertInstanceOf(FlashMessages::class, $result);
 }
开发者ID:omusico,项目名称:zf2-demo,代码行数:7,代码来源:FlashMessagesSLFactoryTest.php

示例2: __invoke

 public function __invoke(ContainerInterface $container)
 {
     $config = $container->has('config') ? $container->get('config') : [];
     $config = isset($config['view_helpers']) ? $config['view_helpers'] : [];
     $manager = new HelperPluginManager(new Config($config));
     $manager->setServiceLocator($container);
     return $manager;
 }
开发者ID:fabiocarneiro,项目名称:zend-expressive-zendviewrenderer,代码行数:8,代码来源:HelperPluginManagerFactory.php

示例3: createService

 /**
  * @test
  * @covers Cocur\Slugify\Bridge\ZF2\SlugifyViewHelperFactory::__invoke()
  */
 public function createService()
 {
     $sm = new ServiceManager();
     $sm->setService('Cocur\\Slugify\\Slugify', new Slugify());
     $vhm = new HelperPluginManager();
     $vhm->setServiceLocator($sm);
     $viewHelper = call_user_func($this->factory, $vhm);
     $this->assertInstanceOf('Cocur\\Slugify\\Bridge\\ZF2\\SlugifyViewHelper', $viewHelper);
 }
开发者ID:ferch01991,项目名称:BlogLaravel,代码行数:13,代码来源:SlugifyViewHelperFactoryTest.php

示例4: setUp

 protected function setUp()
 {
     $this->request = new Request();
     $serviceManager = new ServiceManager();
     $serviceManager->setService('request', $this->request);
     $pluginManager = new HelperPluginManager();
     $pluginManager->setServiceLocator($serviceManager);
     $this->pluginManager = $pluginManager;
 }
开发者ID:jmleroux,项目名称:jmlzf-helpers,代码行数:9,代码来源:QueryParamsTest.php

示例5: testFactory

 public function testFactory()
 {
     $serviceManager = new ServiceManager();
     $pluginManager = new HelperPluginManager();
     $pluginManager->setServiceLocator($serviceManager);
     $serviceManager->setService('ZfjRbac\\Service\\RoleService', $this->getMock('ZfjRbac\\Service\\RoleService', [], [], '', false));
     $factory = new HasRoleViewHelperFactory();
     $viewHelper = $factory->createService($pluginManager);
     $this->assertInstanceOf('ZfjRbac\\View\\Helper\\HasRole', $viewHelper);
 }
开发者ID:joacub,项目名称:zfj-rbac,代码行数:10,代码来源:HasRoleViewHelperFactoryTest.php

示例6: testFactory

 public function testFactory()
 {
     $serviceManager = new ServiceManager();
     $pluginManager = new HelperPluginManager();
     $pluginManager->setServiceLocator($serviceManager);
     $serviceManager->setService('ZfcRbac\\Service\\AuthorizationService', $this->getMock('ZfcRbac\\Service\\AuthorizationServiceInterface'));
     $factory = new IsGrantedViewHelperFactory();
     $isGranted = $factory->createService($pluginManager);
     $this->assertInstanceOf('ZfcRbac\\View\\Helper\\IsGranted', $isGranted);
 }
开发者ID:adamh114,项目名称:zfc-rbac,代码行数:10,代码来源:IsGrantedViewHelperFactoryTest.php

示例7: testFactory

 public function testFactory()
 {
     $sm = new ServiceManager();
     $sm->setService(BlockPoolInterface::class, $this->blockPool);
     $helperManager = new HelperPluginManager();
     $helperManager->setServiceLocator($sm);
     $factory = new BlockFactory();
     $helper = $factory->createService($helperManager);
     $this->assertInstanceOf(Block::class, $helper);
     $this->assertInstanceOf(AbstractHelper::class, $helper);
 }
开发者ID:hummer2k,项目名称:conlayout,代码行数:11,代码来源:BlockFactoryTest.php

示例8: testCanCreateServiceWithName

 public function testCanCreateServiceWithName()
 {
     $moduleOptions = new ModuleOptions(['view_helpers' => ['headLink' => ['proxy' => TestProxy::class]]]);
     $sm = new ServiceManager();
     $sm->setService(ModuleOptions::class, $moduleOptions);
     $viewHelperManager = new HelperPluginManager();
     $viewHelperManager->setServiceLocator($sm);
     $viewHelperManager->setInvokableClass(TestProxy::class, TestProxy::class);
     $factory = new ViewHelperProxyAbstractFactory();
     $this->assertTrue($factory->canCreateServiceWithName($viewHelperManager, TestProxy::class, TestProxy::class));
     $this->assertFalse($factory->canCreateServiceWithName($viewHelperManager, 'not-exist', 'not-exist'));
 }
开发者ID:hummer2k,项目名称:conlayout,代码行数:12,代码来源:AbstractFactoryTest.php

示例9: setUp

 protected function setUp()
 {
     $router = new Router();
     $router->addRoute('home', array('type' => 'Zend\\Mvc\\Router\\Http\\Literal', 'options' => array('route' => '/')));
     $router->addRoute('default', array('type' => 'Zend\\Mvc\\Router\\Http\\Segment', 'options' => array('route' => '/:controller[/:action]')));
     $this->request = new Request();
     $serviceManager = new ServiceManager();
     $serviceManager->setService('router', $router);
     $serviceManager->setService('request', $this->request);
     $pluginManager = new HelperPluginManager();
     $pluginManager->setServiceLocator($serviceManager);
     $this->pluginManager = $pluginManager;
 }
开发者ID:jmleroux,项目名称:jmlzf-helpers,代码行数:13,代码来源:CurrentRouteTest.php

示例10: testFactoryReturnsInstanceOfParamsHelper

 public function testFactoryReturnsInstanceOfParamsHelper()
 {
     $factory = new Factory();
     $sm = new ServiceManager();
     $event = new MvcEvent();
     $application = $this->getMockBuilder('\\Zend\\Mvc\\Application')->disableOriginalConstructor()->setMethods(array('getMvcEvent'))->getMock();
     $application->expects($this->once())->method('getMvcEvent')->will($this->returnValue($event));
     $sm->setService('Application', $application);
     $hm = new HelperPluginManager();
     $hm->setServiceLocator($sm);
     $helper = $factory->createService($hm);
     $this->assertInstanceOf('\\Core\\View\\Helper\\Params', $helper);
 }
开发者ID:cross-solution,项目名称:yawik,代码行数:13,代码来源:ParamsHelperFactoryTest.php

示例11: testCreateService

 public function testCreateService()
 {
     $this->applicationMock->expects($this->once())->method('getMvcEvent')->willReturnSelf();
     $this->applicationMock->expects($this->once())->method('getRouteMatch')->willReturn(new RouteMatch([]));
     $sl = Bootstrap::getServiceManager();
     $sl->setAllowOverride(true);
     $sl->setService('Application', $this->applicationMock);
     $sl->setAllowOverride(false);
     $helperPluginManager = new HelperPluginManager();
     $helperPluginManager->setServiceLocator($sl);
     $result = $this->testedObj->createService($helperPluginManager);
     $this->assertInstanceOf(LanguagesSwitcher::class, $result);
 }
开发者ID:omusico,项目名称:zf2-demo,代码行数:13,代码来源:LanguagesSwitcherSLFactoryTest.php

示例12: testGenerateViewHelpers

 public function testGenerateViewHelpers()
 {
     $config = (new Module())->getConfig();
     $helperPluginManager = new HelperPluginManager();
     $helperPluginManager->setServiceLocator(new ServiceManager());
     $filterManager = new FilterPluginManager();
     $basePath = $helperPluginManager->get('basePath');
     $basePath->setBasePath('/assets');
     $basePathFilter = new BasePathFilter($basePath);
     $filterManager->setService('basePath', $basePathFilter);
     $cacheBusterFilter = new CacheBusterFilter(__DIR__ . '/_files');
     $filterManager->setService('cacheBuster', $cacheBusterFilter);
     $generator = new ViewHelperGenerator($filterManager, $helperPluginManager, $config['con-layout']['view_helpers']);
     $renderer = new PhpRenderer();
     $renderer->setHelperPluginManager($helperPluginManager);
     /* @var $headLink HeadLink */
     $headLink = $helperPluginManager->get('headLink');
     $headLinkProxy = new HeadLinkProxy($headLink);
     $helperPluginManager->setService(get_class($headLinkProxy), $headLinkProxy);
     /* @var $headScript HeadScript */
     $headScript = $helperPluginManager->get('headScript');
     $headScriptProxy = new HeadScriptProxy($headScript);
     $helperPluginManager->setService(get_class($headScriptProxy), $headScriptProxy);
     /* @var $doctype Doctype */
     $doctype = $helperPluginManager->get('doctype');
     $doctype('HTML5');
     /* @var $headTitle HeadTitle */
     $headTitle = $helperPluginManager->get('headTitle');
     $headTitleProxy = new HeadTitleProxy($headTitle);
     $helperPluginManager->setService(get_class($headTitleProxy), $headTitleProxy);
     /* @var $headMeta HeadMeta */
     $headMeta = $helperPluginManager->get('headMeta');
     $headMetaProxy = new HeadMetaProxy($headMeta);
     $helperPluginManager->setService(get_class($headMetaProxy), $headMetaProxy);
     $headMeta->setView($renderer);
     $generator->generate($this->getLayoutStructure());
     foreach (['/assets/css/test.css', '/assets/css/main.css'] as $expected) {
         $this->assertContains($expected, $headLink->toString());
     }
     foreach (['jquery.min.js', 'jquery-ui.min.js'] as $expected) {
         $this->assertContains($expected, $headScript->toString());
     }
     $this->assertEquals('<!DOCTYPE html>', (string) $doctype);
     $headTitle->setSeparator(' | ');
     $expected = 'First | My Title | Another Title';
     $this->assertContains($expected, $headTitle->toString());
     $contains = ['charset="utf8"', 'name="description" content="My description"', 'name="keywords" content="keyword1, keyword2, keyword3"'];
     foreach ($contains as $expected) {
         $this->assertContains($expected, $headMeta->toString());
     }
 }
开发者ID:hummer2k,项目名称:conlayout,代码行数:51,代码来源:ViewHelperGeneratorTest.php

示例13: createServiceLocator

 /**
  * @return ServiceLocatorInterface
  */
 private function createServiceLocator(MvcEvent $e = null)
 {
     $sm = new ServiceManager();
     $sm->setService('Request', new Request());
     $sm->setService('Response', new Response());
     $sm->setService('EventManager', new EventManager());
     $sm->setService('Router', TreeRouteStack::factory(['routes' => []]));
     $e = $e ?: new MvcEvent();
     $app = $this->prophesize('Zend\\Mvc\\Application');
     $app->getMvcEvent()->willReturn($e);
     $sm->setService('Application', $app->reveal());
     $helperManager = new HelperPluginManager();
     $helperManager->setServiceLocator($sm);
     return $helperManager;
 }
开发者ID:shitikovkirill,项目名称:LearnZF2,代码行数:18,代码来源:QueryUrlFactoryTest.php

示例14: createServiceLocator

 /**
  * @return ServiceLocatorInterface
  */
 private function createServiceLocator(MvcEvent $e = null)
 {
     $sm = new ServiceManager();
     $sm->setService('Request', new Request());
     $sm->setService('Response', new Response());
     $sm->setService('EventManager', new EventManager());
     $sm->setService('Router', TreeRouteStack::factory(['routes' => []]));
     $e = $e ?: new MvcEvent();
     $app = $this->getMock('Zend\\Mvc\\Application', [], [[], $sm]);
     $app->expects($this->any())->method('getMvcEvent')->willReturn($e);
     $sm->setService('Application', $app);
     $helperManager = new HelperPluginManager();
     $helperManager->setServiceLocator($sm);
     return $helperManager;
 }
开发者ID:jkhaled,项目名称:LearnZF2,代码行数:18,代码来源:QueryUrlFactoryTest.php

示例15: testInvokeAppendsJsApiUrlToHeadScriptHelper

 public function testInvokeAppendsJsApiUrlToHeadScriptHelper()
 {
     $cleengApi = $this->getMock('Cleeng_Api', array('getJsApiUrl'));
     $cleengApi->expects($this->once())->method('getJsApiUrl')->will($this->returnValue('https://cleeng.com/api-endpoint'));
     $headScript = $this->getMock('Zend\\View\\Helper\\HeadScript', array('appendFile'));
     $headScript->expects($this->once())->method('appendFile')->with('https://cleeng.com/api-endpoint');
     $sm = new ServiceManager();
     $sm->setService('Cleeng\\Api', $cleengApi);
     $pluginManager = new HelperPluginManager();
     $pluginManager->setServiceLocator($sm);
     $view = $this->getMock('Zend\\View\\Renderer\\PhpRenderer', array('plugin'));
     $view->expects($this->once())->method('plugin')->with('headScript')->will($this->returnValue($headScript));
     $helper = new EnableCleengJsApi();
     $helper->setServiceLocator($pluginManager);
     $helper->setView($view);
     $helper->__invoke();
 }
开发者ID:cleeng,项目名称:cleeng-api-module,代码行数:17,代码来源:EnableCleengJsApiTest.php


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