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