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


PHP HelperPluginManager::get方法代码示例

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


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

示例1: getViewHelper

 /**
  * 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);
 }
开发者ID:patrova,项目名称:omeka-s,代码行数:13,代码来源:AbstractRepresentation.php

示例2: applyViewHelpers

 /**
  * applies view helpers
  *
  * @todo refactor
  * @param MvcEvent $e
  * @return LayoutModifierListener
  */
 public function applyViewHelpers(EventInterface $e)
 {
     $viewHelperInstructions = $this->updater->getLayoutStructure()->get(LayoutUpdaterInterface::INSTRUCTION_VIEW_HELPERS);
     if ($viewHelperInstructions instanceof Config) {
         $viewHelperInstructions = $viewHelperInstructions->toArray();
     }
     foreach ($this->helperConfig as $helper => $config) {
         if (!isset($viewHelperInstructions[$helper])) {
             continue;
         }
         $defaultMethod = isset($config['default_method']) ? $config['default_method'] : '__invoke';
         $viewHelper = $this->viewHelperManager->get($helper);
         $viewHelperInstructions[$helper] = (array) $viewHelperInstructions[$helper];
         foreach ($viewHelperInstructions[$helper] as $value) {
             if (!$value) {
                 continue;
             }
             $value = (array) $value;
             $method = $this->getHelperMethod($value, $defaultMethod, $viewHelper);
             $args = isset($value['args']) ? (array) $value['args'] : array_values($value);
             $args[0] = $this->prepareHelperValue($args[0], $helper);
             call_user_func_array([$viewHelper, $method], $args);
         }
     }
     return $this;
 }
开发者ID:adamdyson,项目名称:ConLayout,代码行数:33,代码来源:ViewHelperListener.php

示例3: __call

 /**
  * Invoke helper manager
  *
  * @param string $name
  * @param array $arguments
  * @return mixed
  */
 public function __call($name, array $arguments = null)
 {
     if (null === $arguments) {
         return $this->helperManager->get($name);
     }
     return call_user_func_array(array($this->helperManager->get($name), '__invoke'), $arguments);
 }
开发者ID:alancrisp,项目名称:zf2twig,代码行数:14,代码来源:PluginProvider.php

示例4: getIdentityHelper

 /**
  * @return Identity
  */
 protected function getIdentityHelper()
 {
     if (!$this->identityHelper instanceof Identity) {
         $identity = $this->serviceLocator->get('identity');
         $this->identityHelper = $identity;
     }
     return $this->identityHelper;
 }
开发者ID:uthando-cms,项目名称:uthando-navigation,代码行数:11,代码来源:NavigationFactory.php

示例5: __call

 public function __call($method, $argv)
 {
     $helper = $this->pluginManager->get($method);
     if (is_callable($helper)) {
         return call_user_func_array($helper, $argv);
     }
     return helper;
 }
开发者ID:vbryan,项目名称:Zend,代码行数:8,代码来源:FormHelper.php

示例6: dateFormat

 /**
  * Format a date.
  *
  * If PHP's intl extension is not loaded, this helper will fall back on a
  * predefined date and time format.
  *
  * @param DateTime $date
  * @param string $dateType Use local DATE_FORMAT_* constants, not their
  *     corresponding constants in IntlDateFormatter.
  * @param string $timeType Use local DATE_FORMAT_* constants, not their
  *     corresponding constants in IntlDateFormatter.
  * @param string|null $locale Optional locale to use when formatting or
  *     parsing. Ignored when intl extension is not loaded.
  * @param string|null $pattern Optional pattern to use when formatting or
  *     parsing. Possible patterns are documented at
  *     {@link http://userguide.icu-project.org/formatparse/datetime}.
  *     Ignored when intl extension is not loaded.
  * @return string
  */
 public function dateFormat(DateTime $date = null, $dateType = self::DATE_FORMAT_MEDIUM, $timeType = self::DATE_FORMAT_NONE, $locale = null, $pattern = null)
 {
     if (!$date) {
         return null;
     }
     if (extension_loaded('intl')) {
         // Map local constants to those in IntlDateFormatter.
         $constMap = [self::DATE_FORMAT_NONE => \IntlDateFormatter::NONE, self::DATE_FORMAT_FULL => \IntlDateFormatter::FULL, self::DATE_FORMAT_LONG => \IntlDateFormatter::LONG, self::DATE_FORMAT_MEDIUM => \IntlDateFormatter::MEDIUM, self::DATE_FORMAT_SHORT => \IntlDateFormatter::SHORT];
         $dateType = array_key_exists($dateType, $constMap) ? $constMap[$dateType] : \IntlDateFormatter::MEDIUM;
         $timeType = array_key_exists($timeType, $constMap) ? $constMap[$timeType] : \IntlDateFormatter::NONE;
         // Proxy to Zend's dateFormat helper.
         $dateFormat = $this->viewHelperManager->get('dateFormat');
         return $dateFormat($date, $dateType, $timeType, $locale, $pattern);
     }
     // Set the date format.
     $dateFormat = '';
     switch ($dateType) {
         case self::DATE_FORMAT_NONE:
             break;
         case self::DATE_FORMAT_FULL:
             $dateFormat .= 'l, F j, Y';
             break;
         case self::DATE_FORMAT_LONG:
             $dateFormat .= 'F j, Y';
             break;
         case self::DATE_FORMAT_SHORT:
             $dateFormat .= 'n/j/y';
             break;
         case self::DATE_FORMAT_MEDIUM:
         default:
             $dateFormat .= 'M j, Y';
             break;
     }
     // Set the time format.
     $timeFormat = '';
     switch ($timeType) {
         case self::DATE_FORMAT_FULL:
             $timeFormat .= 'g:i:sa T';
             break;
         case self::DATE_FORMAT_LONG:
             $timeFormat .= 'g:i:sa';
             break;
         case self::DATE_FORMAT_MEDIUM:
             $timeFormat .= 'g:ia';
             break;
         case self::DATE_FORMAT_SHORT:
             $timeFormat .= 'g:ia';
             break;
         case self::DATE_FORMAT_NONE:
         default:
             break;
     }
     return $date->format(trim("{$dateFormat} {$timeFormat}"));
 }
开发者ID:patrova,项目名称:omeka-s,代码行数:73,代码来源:I18n.php

示例7: perform_do

 public function perform_do($args)
 {
     $name = array_shift($args);
     if (is_string($name) == false) {
         return null;
     }
     if ($this->helpers->has($name) == false) {
         return null;
     }
     call_user_func_array($this->helpers->get($name), $args);
 }
开发者ID:ngyuki,项目名称:zf2-smarty,代码行数:11,代码来源:CompilerPlugin.php

示例8: testInstance

 /**
  * A test class of instance
  */
 public function testInstance()
 {
     $moduleConfig = (require __DIR__ . '/../../../config/module.config.php');
     $serviceManager = new ServiceManager($moduleConfig['service_manager']);
     $helperPluginManager = new HelperPluginManager($serviceManager, $moduleConfig['view_helpers']);
     $signInForm = new SignInForm();
     $formBuilderHelper1 = $helperPluginManager->get('formBuilder');
     $formBuilderHelper1()->setToken('test token 1');
     $this->assertInstanceOf(FormBuilder::class, $formBuilderHelper1());
     $formBuilderHelper2 = $helperPluginManager->get(FormBuilderHelper::class);
     $formBuilderHelper2()->setToken('test token 2');
     $this->assertInstanceOf(FormBuilder::class, $formBuilderHelper2($signInForm));
     $this->assertNotEquals($formBuilderHelper1(), $formBuilderHelper2());
 }
开发者ID:bupy7,项目名称:zf-form,代码行数:17,代码来源:FormBuilderHelperFactoryTest.php

示例9: testHelperService

 /**
  * Test if the helper is properly registered with the service manager
  */
 public function testHelperService()
 {
     // Uppercase
     $this->assertInstanceOf(static::_getHelperClass(), static::$_helperManager->get($this->_getHelperName()));
     // Lowercase
     $this->assertInstanceOf(static::_getHelperClass(), static::$_helperManager->get(lcfirst($this->_getHelperName())));
 }
开发者ID:hschletz,项目名称:braintacle,代码行数:10,代码来源:AbstractTest.php

示例10: get

 /**
  * Retrieve a service from the manager by name
  *
  * Allows passing an array of options to use when creating the instance.
  * createFromInvokable() will use these and pass them to the instance
  * constructor if not null and a non-empty array.
  *
  * @param  string $name
  * @param  array $options
  * @param  bool $usePeeringServiceManagers
  * @return Helper\HelperInterface
  */
 public function get($name, $options = array(), $usePeeringServiceManagers = true)
 {
     // Canonize invokable class from name
     if (!$this->has($name) && !class_exists($name)) {
         // Lookup in default invokable list
         $cname = strtolower(str_replace(array('-', '_', ' ', '\\', '/'), '', $name));
         if (isset($this->invokableList[$cname])) {
             $invokableClass = 'Pi\\' . $this->invokableList[$cname];
             if (!class_exists($invokableClass)) {
                 $invokableClass = 'Zend\\' . $this->invokableList[$cname];
             }
             $name = $invokableClass;
             // Lookup in helper locations
         } else {
             $class = str_replace(' ', '', ucwords(str_replace(array('-', '_', '.', '\\', '/'), ' ', $name)));
             foreach ($this->helperLocations as $location) {
                 $invokableClass = 'Pi\\' . $location . '\\' . $class;
                 if (class_exists($invokableClass)) {
                     $name = $invokableClass;
                     break;
                 } else {
                     $invokableClass = 'Zend\\' . $location . '\\' . $class;
                     if (class_exists($invokableClass)) {
                         $name = $invokableClass;
                         break;
                     }
                 }
             }
         }
     }
     return parent::get($name, $options, $usePeeringServiceManagers);
 }
开发者ID:Andyyang1981,项目名称:pi,代码行数:44,代码来源:ViewHelperManager.php

示例11: parseCountryMap

 /**
  * @return null|string
  */
 public function parseCountryMap()
 {
     $mapOptions = ['clickable' => true, 'colorMin' => $this->getModuleOptions()->getCountryColorFaded(), 'colorMax' => $this->getModuleOptions()->getCountryColor(), 'focusOn' => ['x' => 0.5, 'y' => 0.5, 'scale' => 1.1], 'height' => '340px'];
     /**
      * @var $countryMap CountryMap
      */
     $countryMap = $this->serviceLocator->get('countryMap');
     return $countryMap([$this->getCountry()], null, $mapOptions);
 }
开发者ID:iteaoffice,项目名称:general,代码行数:12,代码来源:CountryHandler.php

示例12: __call

 /**
  * Provides access to view helpers.
  * 
  * @param string $method
  * @param array $args
  * @return mixed
  */
 public function __call($method, $args)
 {
     if (!isset($this->_helperCache[$method])) {
         $helper = $this->_helperManager->get($method);
         $helper->setView($this);
         $this->_helperCache[$method] = $helper;
     }
     return call_user_func_array($this->_helperCache[$method], $args);
 }
开发者ID:Kingbalou,项目名称:cronkeep,代码行数:16,代码来源:View.php

示例13: createImageUrl

 /**
  * This function produces the link in the end
  *
  * @return string
  */
 public function createImageUrl()
 {
     /**
      * @var $url Url
      */
     $url = $this->serviceLocator->get('url');
     /**
      * @var $config array
      */
     $config = $this->serviceLocator->getServiceLocator()->get('config');
     $cdn = null;
     if (isset($config['cdn']) && $config['cdn']['enable']) {
         $cdn = $config['cdn']['address'];
     }
     $imageUrl = '<img src="%s%s" id="%s" class="%s" %s>';
     $image = sprintf($imageUrl, $cdn, $url($this->router, $this->routerParams), $this->imageId, implode(' ', $this->classes), is_null($this->height) ? null : ' height="' . $this->height . 'px"');
     if (!$this->lightBox) {
         return $image;
     } else {
         return '<a href="' . $url($this->router, $this->routerParams) . '" data-lightbox="itea">' . $image . '</a>';
     }
 }
开发者ID:debranova,项目名称:contact,代码行数:27,代码来源:ImageAbstract.php

示例14: __invoke

 /**
  * createService
  *
  * Create the form group helper.
  *
  * @param  HelperPluginManager  $viewHelperManager  The view helper plugin manager.
  * @param  string               $name               The name of the service to create.
  * @param  string               $requestedName      The requested name of the service to create.
  *
  * @return FormGroup
  */
 public function __invoke(HelperPluginManager $viewHelperManager, $name, $requestedName)
 {
     /** @var ServiceManager $serviceManager */
     $serviceManager = $viewHelperManager->getServiceLocator();
     $options = $this->getOptions($serviceManager, $requestedName);
     $formRowHelper = $this->defaultRowHelper;
     if (!empty($options['form_row_helper'])) {
         $formRowHelper = $options['form_row_helper'];
     }
     /** @var FormRow $formRow */
     $formRow = $viewHelperManager->get($formRowHelper);
     return new FormGroup($formRow);
 }
开发者ID:alex-patterson-webdev,项目名称:arp-form,代码行数:24,代码来源:FormGroupFactory.php

示例15: 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


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