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


PHP HelperPluginManager::setFactory方法代码示例

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


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

示例1: injectOverrideFactories

 /**
  * @param HelperPluginManager $plugins
  * @param ContainerInterface $container
  * @return HelperPluginManager
  */
 private function injectOverrideFactories(HelperPluginManager $plugins, ContainerInterface $container)
 {
     $urlFactory = $this->createUrlHelperFactory($container);
     $plugins->setFactory(ViewHelper\Url::class, $urlFactory);
     $plugins->setFactory('zendviewhelperurl', $urlFactory);
     $basePathFactory = $this->createBasePathHelperFactory($container);
     $plugins->setFactory(ViewHelper\BasePath::class, $basePathFactory);
     $plugins->setFactory('zendviewhelperbasepath', $basePathFactory);
     return $plugins;
 }
开发者ID:zendframework,项目名称:zend-mvc-console,代码行数:15,代码来源:ConsoleViewHelperManagerDelegatorFactory.php

示例2: __invoke

 /**
  * @param ContainerInterface $container
  * @throws \RuntimeException
  * @return HelperPluginManager
  */
 public function __invoke(ContainerInterface $container)
 {
     $helperPluginManager = new HelperPluginManager();
     $config = $container->has('config') ? $container->get('config') : [];
     if (isset($config['templates']['plugins'])) {
         foreach ($config['templates']['plugins'] as $pluginName => $serviceName) {
             $helperPluginManager->setFactory($pluginName, function () use($container, $serviceName) {
                 return $container->get($serviceName);
             });
         }
     }
     return $helperPluginManager;
 }
开发者ID:josecelano,项目名称:proophessor-do,代码行数:18,代码来源:ViewHelperPluginManagerFactory.php

示例3: injectOverrideFactories

 /**
  * Inject override factories into the plugin manager.
  *
  * @param HelperPluginManager $plugins
  * @param ContainerInterface $services
  * @return HelperPluginManager
  */
 private function injectOverrideFactories(HelperPluginManager $plugins, ContainerInterface $services)
 {
     // Configure URL view helper
     $urlFactory = $this->createUrlHelperFactory($services);
     $plugins->setFactory(ViewHelper\Url::class, $urlFactory);
     $plugins->setFactory('zendviewhelperurl', $urlFactory);
     // Configure base path helper
     $basePathFactory = $this->createBasePathHelperFactory($services);
     $plugins->setFactory(ViewHelper\BasePath::class, $basePathFactory);
     $plugins->setFactory('zendviewhelperbasepath', $basePathFactory);
     // Configure doctype view helper
     $doctypeFactory = $this->createDoctypeHelperFactory($services);
     $plugins->setFactory(ViewHelper\Doctype::class, $doctypeFactory);
     $plugins->setFactory('zendviewhelperdoctype', $doctypeFactory);
     return $plugins;
 }
开发者ID:zendframework,项目名称:zend-mvc,代码行数:23,代码来源:ViewHelperManagerFactory.php

示例4: injectHelpers

 /**
  * Inject helpers into the PhpRenderer instance.
  *
  * If a HelperPluginManager instance is present in the container, uses that;
  * otherwise, instantiates one.
  *
  * In each case, injects with the custom url/serverurl implementations.
  *
  * @param PhpRenderer $renderer
  * @param ContainerInterface $container
  */
 private function injectHelpers(PhpRenderer $renderer, HelperPluginManager $manager)
 {
     $manager->setFactory('url', function () use($container) {
         if (!$container->has(BaseUrlHelper::class)) {
             throw new Exception\MissingHelperException(sprintf('An instance of %s is required in order to create the "url" view helper; not found', BaseUrlHelper::class));
         }
         return new UrlHelper($container->get(BaseUrlHelper::class));
     });
     $manager->setFactory('serverurl', function () use($container) {
         if (!$container->has(BaseServerUrlHelper::class)) {
             throw new Exception\MissingHelperException(sprintf('An instance of %s is required in order to create the "url" view helper; not found', BaseServerUrlHelper::class));
         }
         return new ServerUrlHelper($container->get(BaseServerUrlHelper::class));
     });
     $renderer->setHelperPluginManager($manager);
 }
开发者ID:fabiocarneiro,项目名称:zend-expressive-zendviewrenderer,代码行数:27,代码来源:ZendViewRendererFactory.php

示例5: setUp

 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     $this->viewHelperPluginManager = new HelperPluginManager();
     $this->viewHelperPluginManager->setFactory('hangerSnippet', 'HangerSnippet\\Service\\SnippetHelperServiceFactory');
 }
开发者ID:ripaclub,项目名称:zf2-hanger-snippet,代码行数:8,代码来源:SnippetHelperServiceFactoryTest.php


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