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


PHP PhpRenderer::setHelperPluginManager方法代码示例

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


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

示例1: onRoute

 public function onRoute(MvcEvent $e)
 {
     $request = $e->getRequest();
     if (!$request instanceof HttpRequest) {
         return;
     }
     $application = $e->getApplication();
     $serviceLocator = $application->getServiceManager();
     // Load the configuration for maintenance mode
     if ($serviceLocator->has('MaintenanceConfig')) {
         $config = $serviceLocator->get('MaintenanceConfig');
     } else {
         $config = new Config();
     }
     if (!$config->isEnabled()) {
         // Maintenance mode is disabled.
         return;
     }
     // Check the white list
     if ($request instanceof PhpRequest) {
         $address = $request->getServer('REMOTE_ADDR', null);
     } else {
         $address = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : null;
     }
     if (!empty($address)) {
         if (in_array($address, $config->getWhitelist())) {
             return;
         }
     }
     // Render the maintenance layout
     $renderer = new PhpRenderer();
     if ($serviceLocator->has('ViewHelperManager')) {
         $renderer->setHelperPluginManager($serviceLocator->get('ViewHelperManager'));
     }
     $resolver = new TemplateMapResolver();
     $resolver->add('maintenance', $config->getTemplate());
     $renderer->setResolver($resolver);
     $content = $renderer->render('maintenance');
     // Set the response
     $response = $e->getResponse();
     if (!$response instanceof HttpResponse) {
         $response = new HttpResponse();
     }
     $statusCode = $config->getStatusCode();
     $response->setStatusCode($statusCode);
     if ($statusCode === 503 && !$response->getHeaders()->has('Retry-After')) {
         $retryDate = $config->getRetryAfter();
         if ($retryDate instanceof DateTime) {
             $retryAfter = new RetryAfter();
             $retryAfter->setDate($retryDate);
             $response->getHeaders()->addHeader($retryAfter);
         }
     }
     $response->setContent($content);
     $e->setResponse($response);
     // Return the response
     return $response;
 }
开发者ID:zend-modules,项目名称:maintenance,代码行数:58,代码来源:MaintenanceListener.php

示例2: setUp

 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  *
  * @return void
  */
 protected function setUp()
 {
     $serviceManager = Registry::get('Application')->getServiceManager();
     $this->renderer = new PhpRenderer();
     $renderer = $serviceManager->get('Zend\\View\\Renderer\\PhpRenderer');
     $this->renderer->setHelperPluginManager($renderer->getHelperPluginManager());
     $serviceManager->setAllowOverride(true);
     $serviceManager->setService('currentDocument', DocumentModel::fromArray(array('id' => 1)));
     $serviceManager->setAllowOverride(false);
     $this->object = $this->renderer->plugin('modulePlugin');
     $this->module = ModuleModel::fromArray(array('name' => 'Blog'));
     $this->module->save();
 }
开发者ID:gotcms,项目名称:gotcms,代码行数:19,代码来源:ModulePluginTest.php

示例3: setUp

 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  *
  * @return void
  */
 protected function setUp()
 {
     $this->view = ViewModel::fromArray(array('name' => 'View Name', 'identifier' => 'View identifier', 'description' => 'View Description', 'content' => 'View Content'));
     $this->view->save();
     $this->layout = LayoutModel::fromArray(array('name' => 'Layout Name', 'identifier' => 'Layout identifier', 'description' => 'Layout Description', 'content' => 'Layout Content'));
     $this->layout->save();
     $this->user = UserModel::fromArray(array('lastname' => 'User test', 'firstname' => 'User test', 'email' => 'pierre.rambaud86@gmail.com', 'login' => 'test', 'user_acl_role_id' => 1));
     $this->user->setPassword('test');
     $this->user->save();
     $this->documentType = DocumentTypeModel::fromArray(array('name' => 'Document Type Name', 'description' => 'Document Type description', 'icon_id' => 1, 'defaultview_id' => $this->view->getId(), 'user_id' => $this->user->getId()));
     $this->documentType->save();
     $this->document = DocumentModel::fromArray(array('name' => 'Document name', 'url_key' => 'url-key', 'status' => DocumentModel::STATUS_ENABLE, 'show_in_nav' => true, 'user_id' => $this->user->getId(), 'document_type_id' => $this->documentType->getId(), 'view_id' => $this->view->getId(), 'layout_id' => $this->layout->getId(), 'parent_id' => null));
     $this->document->save();
     $serviceManager = Registry::get('Application')->getServiceManager();
     $this->renderer = new PhpRenderer();
     $renderer = $serviceManager->get('Zend\\View\\Renderer\\PhpRenderer');
     $this->renderer->setHelperPluginManager($renderer->getHelperPluginManager());
     $serviceManager->setAllowOverride(true);
     $serviceManager->setService('currentDocument', $this->document);
     $serviceManager->setAllowOverride(false);
     $this->object = new CommentForm();
     $this->module = ModuleModel::fromArray(array('name' => 'Blog'));
     $this->module->save();
     $this->boostrap = new Module();
     $this->boostrap->install();
 }
开发者ID:gotcms,项目名称:gotcms,代码行数:32,代码来源:CommentFormTest.php

示例4: testApplyViewHelpers

 public function testApplyViewHelpers()
 {
     $config = Bootstrap::getServiceManager()->get('Config');
     $helperPluginManager = new HelperPluginManager();
     $listener = new ViewHelperListener($this->layoutUpdater, $helperPluginManager, $config['con-layout']['view_helpers']);
     $mvcEvent = new \Zend\Mvc\MvcEvent();
     $renderer = new PhpRenderer();
     $renderer->setHelperPluginManager($helperPluginManager);
     $basePath = $helperPluginManager->get('basePath');
     $basePath->setBasePath('/assets');
     $basePathAssetPreparer = new BasePath($basePath);
     $listener->addAssetPreparer('headLink', $basePathAssetPreparer);
     /* @var $headLink HeadLink */
     $headLink = $helperPluginManager->get('headLink');
     /* @var $headScript HeadScript */
     $headScript = $helperPluginManager->get('headScript');
     /* @var $doctype \Zend\View\Helper\Doctype */
     $doctype = $helperPluginManager->get('doctype');
     /* @var $headTitle HeadTitle */
     $headTitle = $helperPluginManager->get('headTitle');
     /* @var $headMeta HeadMeta */
     $headMeta = $helperPluginManager->get('headMeta');
     $headMeta->setView($renderer);
     $listener->applyViewHelpers($mvcEvent);
     $expected = '<link href="/assets/css/test.css" media="screen" rel="stylesheet" type="text/css">' . PHP_EOL . '<link href="/assets/css/main.css" media="screen" rel="stylesheet" type="text/css">';
     $this->assertEquals($expected, $headLink->toString());
     $expected = '<script type="text/javascript" src="/js/jquery.min.js"></script>' . PHP_EOL . '<script type="text/javascript" src="/js/jquery-ui.min.js"></script>' . PHP_EOL . '<!--[if lt IE 9]><script type="text/javascript" src="/js/modernizr.js"></script><![endif]-->' . PHP_EOL . '<script type="text/javascript" src="/js/functions.js"></script>';
     $this->assertEquals($expected, $headScript->toString());
     $this->assertEquals('<!DOCTYPE html>', (string) $doctype);
     $headTitle->setSeparator(' | ');
     $expected = '<title>First | My Title | Another Title</title>';
     $this->assertEquals($expected, $headTitle->toString());
     $expected = '<meta charset="utf8">' . PHP_EOL . '<meta name="description" content="My description">' . PHP_EOL . '<meta name="keywords" content="keyword1, keyword2, keyword3">';
     $this->assertEquals($expected, $headMeta->toString());
 }
开发者ID:adamdyson,项目名称:ConLayout,代码行数:35,代码来源:ViewHelperListenerTest.php

示例5: __invoke

 /**
  * @param  ContainerInterface $container
  * @param  string $name
  * @param  null|array $options
  * @return PhpRenderer
  */
 public function __invoke(ContainerInterface $container, $name, array $options = null)
 {
     $renderer = new PhpRenderer();
     $renderer->setHelperPluginManager($container->get('ViewHelperManager'));
     $renderer->setResolver($container->get('ViewResolver'));
     return $renderer;
 }
开发者ID:kuisatz,项目名称:ustalarMerkezi,代码行数:13,代码来源:ViewPhpRendererFactory.php

示例6: setUp

 public function setUp()
 {
     $this->wrapperHelper = new Wrapper();
     $view = new PhpRenderer();
     $view->setHelperPluginManager(new HelperPluginManager());
     $this->wrapperHelper->setView($view);
 }
开发者ID:hummer2k,项目名称:conlayout,代码行数:7,代码来源:WrapperTest.php

示例7: testCanRenderFieldsets

 /**
  * @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', '/');
 }
开发者ID:netsensia,项目名称:zf2-foundation,代码行数:31,代码来源:BootstrapFormTest.php

示例8: __invoke

 /**
  * @param ContainerInterface $container
  *
  * @return PhpRenderer
  */
 public function __invoke(ContainerInterface $container)
 {
     $helper = $container->get(HelperPluginManager::class);
     $renderer = new PhpRenderer();
     $renderer->setHelperPluginManager($helper);
     return $renderer;
 }
开发者ID:oqq,项目名称:ci-zend-form-twig-extension,代码行数:12,代码来源:ZendFormPhpRendererFactory.php

示例9: testCompatibilityWithZF2View

 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}());
 }
开发者ID:tworzenieweb,项目名称:zf-bc-view-helpers,代码行数:9,代码来源:JobleadsHelperTest.php

示例10: checkRenderer

 /**
  * Check renderer, create if not exists
  * Copy helper plugin manager from application service manager
  *
  * @return \Gc\View\Renderer
  */
 protected function checkRenderer()
 {
     if (is_null($this->renderer)) {
         $this->renderer = new PhpRenderer();
         $renderer = Registry::get('Application')->getServiceManager()->get('Zend\\View\\Renderer\\PhpRenderer');
         $this->renderer->setHelperPluginManager(clone $renderer->getHelperPluginManager());
         $this->renderer->setResolver(new TemplatePathStack());
     }
     return $this;
 }
开发者ID:gotcms,项目名称:gotcms,代码行数:16,代码来源:Renderer.php

示例11: createService

 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $renderer = new PhpRenderer();
     $helperManager = $serviceLocator->get('ViewHelperManager');
     $resolver = $serviceLocator->get('ViewResolver');
     $renderer->setHelperPluginManager($helperManager);
     $renderer->setResolver($resolver);
     $model = $serviceLocator->get('Application')->getMvcEvent()->getViewModel();
     $modelHelper = $renderer->plugin('view_model');
     $modelHelper->setRoot($model);
     return $renderer;
 }
开发者ID:finbarrmccarthy,项目名称:mailservice,代码行数:12,代码来源:MailPhpRendererFactory.php

示例12: __invoke

 /**
  * @param ContainerInterface $container
  * @return PhpRenderer
  */
 public function __invoke(ContainerInterface $container)
 {
     $config = $container->get('config');
     $viewHelperPluginManager = $container->get(HelperPluginManager::class);
     // Create the engine instance:
     $renderer = new PhpRenderer();
     // Configure it:
     $resolver = new Resolver\AggregateResolver();
     $resolver->attach(new Resolver\TemplateMapResolver($config['templates']), 100);
     $renderer->setResolver($resolver);
     $renderer->setHelperPluginManager($viewHelperPluginManager);
     return $renderer;
 }
开发者ID:renereed1,项目名称:proophessor-do,代码行数:17,代码来源:PhpRendererFactory.php

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

示例14: getView

 /**
  *
  * @return \Zend\View\View
  */
 public function getView()
 {
     if ($this->view) {
         return $this->view;
     }
     $helperManager = $this->serviceLocator->get('ViewHelperManager');
     $resolver = $this->serviceLocator->get('ViewResolver');
     $renderer = new PhpRenderer();
     $renderer->setHelperPluginManager($helperManager);
     $renderer->setResolver($resolver);
     $rendererStrategy = new PhpRendererStrategy($renderer);
     $this->view = new View();
     $this->view->setEventManager($this->serviceLocator->get('EventManager'));
     $this->view->getEventManager()->attach($rendererStrategy);
     return $this->view;
 }
开发者ID:ebittleman,项目名称:mailgun-zf2,代码行数:20,代码来源:MessageRenderer.php

示例15: testInvoke

 public function testInvoke()
 {
     $helper = new DisplayImage();
     $helper->setAttributes(['alt' => 'hello']);
     $renderer = new PhpRenderer();
     $helpers = new HelperPluginManager();
     $renderer->setHelperPluginManager($helpers);
     $doctype = $this->getMock('Zend\\View\\Helper\\Doctype');
     $doctype->expects($this->once())->method('isXhtml')->will($this->returnValue(true));
     $helpers->setService('doctype', $doctype);
     $imgUrl = $this->getMockBuilder('HtImgModule\\View\\Helper\\ImgUrl')->disableOriginalConstructor()->getMock();
     $imgUrl->expects($this->once())->method('__invoke')->will($this->returnValue('app'));
     $helpers->setService('HtImgModule\\View\\Helper\\ImgUrl', $imgUrl);
     $helper->setView($renderer);
     $this->assertEquals('<img alt="hello" src="app" />', $helper('asdfsadf', 'asdfasfd'));
     $this->assertEquals($helper, $helper());
 }
开发者ID:shitikovkirill,项目名称:zend-shop.com,代码行数:17,代码来源:DisplayImageTest.php


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