php Zend-View-HelperPluginManager类(方法)实例源码

下面列出了php Zend-View-HelperPluginManager 类(方法)源码代码实例,从而了解它的用法。

作者:netsensi    项目:zf2-foundatio   
/**
  * @outputBuffering disabled
  */
 public function testCanRenderFieldsets()
 {
     $this->expectOutputRegex('/<form(.*)<fieldset(.*)<\\/fieldset>(.*)<fieldset(.*)<\\/fieldset>(.*)<\\/form>/');
     $form = new NetsensiaForm();
     $form->addHidden('test1', 'testvalue');
     $hidden = new Element\Hidden('asdasd');
     $hidden->setValue('123');
     $form->add($hidden);
     $element1 = new Text('testelement1');
     $element1->setLabel('Test Element');
     $element1->setAttribute('icon', 'pencil');
     $element2 = new Text('testelement2');
     $element2->setLabel('Test Element 2');
     $element2->setAttribute('icon', 'pencil');
     $fieldset1 = new Fieldset('testfieldset1');
     $fieldset1->add($element1);
     $fieldset2 = new Fieldset('testfieldset2');
     $fieldset2->add($element2);
     $form->add($fieldset1);
     $form->add($fieldset2);
     $helpers = new HelperPluginManager();
     $helpers->setService('formElement', new FormElement());
     $view = new PhpRenderer();
     $view->setHelperPluginManager($helpers);
     $viewHelper = new BootstrapForm();
     $viewHelper->setView($view);
     $viewHelper($form, 'testform', '/');
 }

作者:fado    项目:symfony-asset-modul   
/**
  * @param HelperPluginManager $pluginManager
  *
  * @return SymfonyAssetViewHelper
  * @throws \Exception
  */
 public function __invoke(HelperPluginManager $pluginManager)
 {
     $serviceLocator = $pluginManager->getServiceLocator();
     $config = $serviceLocator->get('Config');
     if (false === isset($config['fadoe_symfony_asset_module'])) {
         throw new \Exception('Config not found');
     }
     $config = $config['fadoe_symfony_asset_module'];
     $packagesService = $serviceLocator->get('FaDoe\\SymfonyAssetModule\\PackagesService');
     $version = $config['version'];
     $versionFormat = $config['version_format'];
     $basePath = $config['base_path'];
     $baseUrls = $config['base_urls'];
     $defaultPackage = $packagesService->createService($version, $versionFormat, $basePath, $baseUrls);
     $namedPackages = [];
     foreach ($config['packages'] as $key => $value) {
         $version = $value['version'];
         $versionFormat = $value['version_format'];
         $basePath = $value['base_path'];
         $baseUrls = $value['base_urls'];
         $namedPackages[$key] = $packagesService->createService($version, $versionFormat, $basePath, $baseUrls);
     }
     $packages = new Packages($defaultPackage, $namedPackages);
     return new SymfonyAssetViewHelper($packages);
 }

作者:shitikovkiril    项目:LearnZF   
public function testOnDispatch()
 {
     // Create MvcEvent
     $e = new MvcEvent();
     $e->setViewModel(new ViewModel());
     $rm = new RouteMatch([]);
     $rm->setParam('controller', 'Application\\Controller\\Download');
     $e->setRouteMatch($rm);
     $e->setTarget(new DownloadController([]));
     // Create EntityManager and EntityRepository
     $moduleDetail = new ModuleList();
     $moduleDetail->setModuleDesc('Pretty description');
     $repo = $this->prophesize('Doctrine\\ORM\\EntityRepository');
     $repo->findOneBy(['moduleName' => 'Application'])->willReturn($moduleDetail);
     $em = $this->prophesize('Doctrine\\ORM\\EntityManager');
     $em->getRepository('Application\\Entity\\ModuleList')->willReturn($repo);
     $this->sm->setService('Doctrine\\ORM\\EntityManager', $em->reveal());
     // Create ViewHelperManager
     $headTitle = new HeadTitle();
     $vhm = new HelperPluginManager();
     $vhm->setService('headTitle', $headTitle);
     $this->sm->setService('ViewHelperManager', $vhm);
     $this->module->onDispatch($e);
     $fbMeta = $e->getViewModel()->getVariable('fbMeta');
     $this->assertEquals(sprintf('%s-Real Live Learn ZF2', $moduleDetail->getModuleDesc()), $fbMeta['title']);
     $this->assertEquals(sprintf('%s-', $moduleDetail->getModuleDesc()), $fbMeta['description']);
 }

作者:patrov    项目:omeka-   
/**
  * Get a view helper from the manager.
  *
  * @param string $name
  * @return TranslatorInterface
  */
 protected function getViewHelper($name)
 {
     if (!$this->viewHelperManager instanceof HelperPluginManager) {
         $this->viewHelperManager = $this->getServiceLocator()->get('ViewHelperManager');
     }
     return $this->viewHelperManager->get($name);
 }

作者:omusic    项目:zf2-dem   
public function testCreateService()
 {
     $helperPluginManager = new HelperPluginManager();
     $helperPluginManager->setServiceLocator(Bootstrap::getServiceManager());
     $result = $this->testedObj->createService($helperPluginManager);
     $this->assertInstanceOf(FlashMessages::class, $result);
 }

作者:jbarentse    项目:dr   
public function setupHelpers()
    {
        if (!$this->router) {
            $this->setupRouter();
        }

        $urlHelper = new UrlHelper();
        $urlHelper->setRouter($this->router);

        $serverUrlHelper = new ServerUrlHelper();
        $serverUrlHelper->setScheme('http');
        $serverUrlHelper->setHost('localhost.localdomain');

        $linksHelper = new HalHelper();
        $linksHelper->setUrlHelper($urlHelper);
        $linksHelper->setServerUrlHelper($serverUrlHelper);

        $this->helpers = $helpers = new HelperPluginManager();
        $helpers->setService('url', $urlHelper);
        $helpers->setService('serverUrl', $serverUrlHelper);
        $helpers->setService('hal', $linksHelper);

        $this->plugins = $plugins = new ControllerPluginManager();
        $plugins->setService('hal', $linksHelper);
    }

作者:heartsentwine    项目:zf2-assetwi   
public function setHelperPluginManager(HelperPluginManager $hpm)
 {
     $hpm->setView($this);
     if ($this->getEnvironment()) {
         $this->getEnvironment()->setHelperPluginManager($hpm);
     }
     return $this;
 }

作者:fabiocarneir    项目:zend-expressive-zendviewrendere   
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;
 }

作者:ferch0199    项目:BlogLarave   
/**
  * @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);
 }

作者:jmlerou    项目:jmlzf-helper   
protected function setUp()
 {
     $this->request = new Request();
     $serviceManager = new ServiceManager();
     $serviceManager->setService('request', $this->request);
     $pluginManager = new HelperPluginManager();
     $pluginManager->setServiceLocator($serviceManager);
     $this->pluginManager = $pluginManager;
 }

作者:tworzeniewe    项目:zf-bc-view-helper   
public function testCompatibilityWithZF2View()
 {
     $renderer = new PhpRenderer();
     $helpers = new HelperPluginManager();
     $name = $this->jobleadsHelper->getName();
     $helpers->setInvokableClass($name, get_class($this->jobleadsHelper));
     $renderer->setHelperPluginManager($helpers);
     $this->assertEquals(self::EXPECTED_RETURN, $renderer->{$name}());
 }

作者:adamh11    项目:zfc-rba   
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);
 }

作者:renereed    项目:proophessor-d   
/**
  * @param ContainerInterface $container
  * @throws \RuntimeException
  * @return HelperPluginManager
  */
 public function __invoke(ContainerInterface $container)
 {
     $helperPluginManager = new HelperPluginManager();
     $helperPluginManager->setRetrieveFromPeeringManagerFirst();
     if (!$container instanceof ServiceManager) {
         throw new \RuntimeException(__CLASS__ . ' can only be used when Zend\\ServiceManager\\ServiceManager is used as container');
     }
     $helperPluginManager->addPeeringServiceManager($container);
     return $helperPluginManager;
 }

作者:Belcebu    项目:BelceburBasi   
public function __construct(HelperPluginManager $pluginManager)
 {
     $this->pluginManager = $pluginManager;
     $this->serviceManager = $pluginManager->getServiceLocator();
     $this->app = $pluginManager->getServiceLocator()->get('Application');
     $this->request = $this->app->getRequest();
     $this->event = $this->app->getMvcEvent();
     $this->em = $this->serviceManager->get('Doctrine\\ORM\\EntityManager');
     $this->translator = $this->serviceManager->get('translator');
 }

作者:joacu    项目:zfj-rba   
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);
 }

作者:hummer2    项目:conlayou   
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);
 }

作者:cross-solutio    项目:yawi   
public function testFactoryReturnsProperConfiguredInstanceOfAuthViewHelperAuth()
 {
     $f = new AuthFactory();
     $sm = new ServiceManager();
     $auth = $this->getMockBuilder('\\Zend\\Authentication\\AuthenticationService')->getMock();
     $sm->setService('AuthenticationService', $auth);
     $hm = new HelperPluginManager();
     $hm->setServicelocator($sm);
     $helper = $f->createService($hm);
     $this->assertInstanceOf('\\Auth\\View\\Helper\\Auth', $helper);
     $this->assertSame($auth, $helper->getService());
 }

作者:alex-patterson-webde    项目:arp-aut   
/**
  * createService
  *
  * Create the identity view helper.
  *
  * @param HelperPluginManager  $viewHelperManager  The service manager instance.
  * @param string               $name            The name of the service being created.
  * @param string               $requestedName   The requested name of the service being created.
  *
  * @return Identity
  */
 public function __invoke(HelperPluginManager $viewHelperManager, $name, $requestedName)
 {
     /** @var ServiceManager $serviceManager */
     $serviceManager = $viewHelperManager->getServiceLocator();
     $options = $this->getOptions($serviceManager, $requestedName);
     if (!isset($options['auth_service'])) {
         throw new ServiceNotCreatedException(sprintf('The \'auth_service\' configuration option is missing for view helper \'%s\'.', $requestedName));
     }
     /** @var AuthenticationServiceInterface $authenticationService */
     $authenticationService = $serviceManager->get($options['auth_service']);
     return new Identity($authenticationService);
 }

作者:hummer2    项目:conlayou   
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'));
 }

作者:jmlerou    项目:jmlzf-helper   
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;
 }


问题


面经


文章

微信
公众号

扫码关注公众号