本文整理匯總了PHP中Zend\View\HelperPluginManager::setService方法的典型用法代碼示例。如果您正苦於以下問題:PHP HelperPluginManager::setService方法的具體用法?PHP HelperPluginManager::setService怎麽用?PHP HelperPluginManager::setService使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Zend\View\HelperPluginManager
的用法示例。
在下文中一共展示了HelperPluginManager::setService方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: setupHelpers
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);
}
示例2: testOnDispatch
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']);
}
示例3: 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', '/');
}
示例4: setUpHelpers
public function setUpHelpers()
{
if (isset($this->helpers)) {
return;
}
$this->setupRouter();
$urlHelper = new UrlHelper();
$urlHelper->setRouter($this->router);
$serverUrlHelper = new ServerUrlHelper();
$serverUrlHelper->setScheme('http');
$serverUrlHelper->setHost('localhost.localdomain');
$this->linksHelper = $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);
}
示例5: testFactory
public function testFactory()
{
$factory = new BasePathFilterFactory();
$viewHelperManager = new HelperPluginManager();
$viewHelperManager->setService('basePath', new BasePath());
$serviceManager = new ServiceManager();
$serviceManager->setService('viewHelperManager', $viewHelperManager);
$filterManager = new FilterPluginManager();
$filterManager->setServiceLocator($serviceManager);
$instance = $factory->createService($filterManager);
$this->assertInstanceOf(BasePathFilter2::class, $instance);
$this->assertInstanceOf(FilterInterface::class, $instance);
}
示例6: setupHelpers
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');
$propertiesHelper = new JsonLDHelper();
$propertiesHelper->setUrlHelper($urlHelper);
$propertiesHelper->setServerUrlHelper($serverUrlHelper);
$propertyExtractor = new PropertyExtractor($serverUrlHelper, $urlHelper);
$propertyCollectionExtractor = new PropertyCollectionExtractor($propertyExtractor);
$propertiesHelper->setPropertyCollectionExtractor($propertyCollectionExtractor);
$this->helpers = $helpers = new HelperPluginManager();
$helpers->setService('url', $urlHelper);
$helpers->setService('serverUrl', $serverUrlHelper);
$helpers->setService('JsonLD', $propertiesHelper);
$this->plugins = $plugins = new ControllerPluginManager();
$plugins->setService('JsonLD', $propertiesHelper);
}
示例7: setUpHelpers
public function setUpHelpers()
{
// need to setup routes
// need to get a url and serverurl helper that have appropriate injections
$this->router = $router = new TreeRouteStack();
$this->entityRoute = new Segment('/resource[/[:id]]');
$this->router->addRoute('resource', $this->entityRoute);
$this->helpers = $helpers = new HelperPluginManager();
$serverUrl = $helpers->get('ServerUrl');
$url = $helpers->get('url');
$url->setRouter($router);
$serverUrl->setScheme('http');
$serverUrl->setHost('localhost.localdomain');
$halLinks = new HalHelper();
$halLinks->setServerUrlHelper($serverUrl);
$halLinks->setUrlHelper($url);
$helpers->setService('Hal', $halLinks);
$this->renderer->setHelperPluginManager($helpers);
}
示例8: injectHalHelper
/**
* Inject the helper manager with the Hal helper
*
* @param HelperPluginManager $helpers
*/
protected function injectHalHelper(HelperPluginManager $helpers)
{
$helper = new HalHelper();
$helper->setView($this);
$helper->setServerUrlHelper($helpers->get('ServerUrl'));
$helper->setUrlHelper($helpers->get('Url'));
$helpers->setService('Hal', $helper);
}