本文整理汇总了PHP中Zend\View\Renderer\PhpRenderer::plugin方法的典型用法代码示例。如果您正苦于以下问题:PHP PhpRenderer::plugin方法的具体用法?PHP PhpRenderer::plugin怎么用?PHP PhpRenderer::plugin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\View\Renderer\PhpRenderer
的用法示例。
在下文中一共展示了PhpRenderer::plugin方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testRaisesExceptionIfViewModelHelperHasNoRoot
public function testRaisesExceptionIfViewModelHelperHasNoRoot()
{
$renderer = new PhpRenderer();
$viewModelHelper = $renderer->plugin('view_model');
$helper = $renderer->plugin('layout');
$this->setExpectedException('Zend\\View\\Exception\\RuntimeException', 'view model');
$helper->setTemplate('foo/bar');
}
示例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();
}
示例3: setUp
public function setUp()
{
$this->resolver = new TemplateMapResolver(array('layout' => __DIR__ . '/../_templates/nested-view-model-layout.phtml', 'child1' => __DIR__ . '/../_templates/nested-view-model-content.phtml', 'child2' => __DIR__ . '/../_templates/nested-view-model-child2.phtml', 'complex' => __DIR__ . '/../_templates/nested-view-model-complexlayout.phtml'));
$this->renderer = $renderer = new PhpRenderer();
$renderer->setCanRenderTrees(true);
$renderer->setResolver($this->resolver);
$this->viewModelHelper = $renderer->plugin('view_model');
$this->helper = $renderer->plugin('render_child_model');
$this->parent = new ViewModel();
$this->parent->setTemplate('layout');
$this->viewModelHelper->setRoot($this->parent);
$this->viewModelHelper->setCurrent($this->parent);
}
示例4: setUp
/**
* @see PHPUnit_Framework_TestCase::setUp()
*/
protected function setUp()
{
$view = new View();
$view->plugin('basepath')->setBasePath('');
$translator = $this->getMockBuilder(Translator::class)->getMock();
$translator->method('translate')->willReturnArgument(0);
$this->fileUploadHelper = new FileUploadHelper();
$this->fileUploadHelper->setView($view);
$this->fileUploadHelper->setTranslator($translator);
}
示例5: testInvoke
public function testInvoke()
{
$renderer = new PhpRenderer();
/* @var $url Url */
$url = $renderer->plugin('url');
$url->setRouter(Bootstrap::getServiceManager()->get('HttpRouter'));
$esiUrl = new EsiUrl();
$esiUrl->setView($renderer);
$this->assertEquals('/esi/my-block', call_user_func($esiUrl, 'my-block'));
$this->assertEquals('/esi/my-block?handles%5B0%5D=handle1&handles%5B1%5D=handle2', call_user_func($esiUrl, 'my-block', ['handle1', 'handle2']));
}
示例6: 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;
}
示例7: getPluginViewData
/**
* Get a plugin instance rendered view.
*
* @param string $pluginName Plugin name
* @param integer $pluginInstanceId Plugin Instance Id
* @param array $pluginInstanceConfig Plugin Instance Config
*
* @return array
* @throws \Rcm\Exception\InvalidPluginException
* @throws \Rcm\Exception\PluginReturnedResponseException
*/
public function getPluginViewData($pluginName, $pluginInstanceId, $pluginInstanceConfig)
{
/** @var \Rcm\Plugin\PluginInterface $controller */
$controller = $this->getPluginController($pluginName);
if (!is_a($controller, '\\Rcm\\Plugin\\PluginInterface')) {
throw new InvalidPluginException('Plugin ' . $controller . ' must implement the PluginInterface');
}
$controller->setRequest($this->request);
$response = new Response();
$controller->setResponse($response);
/** @var \Zend\Mvc\MvcEvent $event */
$event = $controller->getEvent();
$event->setRequest($this->request);
$event->setResponse($response);
$controller->setEvent($event);
$viewModel = $controller->renderInstance($pluginInstanceId, $pluginInstanceConfig);
if ($viewModel instanceof ResponseInterface) {
$event = new ViewEvent();
$event->setResponse($viewModel);
$this->eventManager->trigger(ViewEvent::EVENT_RESPONSE, $event);
return null;
}
/** @var \Zend\View\Helper\Headlink $headlink */
$headlink = $this->renderer->plugin('headlink');
/** @var \Zend\View\Helper\HeadScript $headScript */
$headScript = $this->renderer->plugin('headscript');
$oldContainer = $headlink->getContainer();
$linkContainer = new Container();
$headlink->setContainer($linkContainer);
$oldScriptContainer = $headScript->getContainer();
$headScriptContainer = new Container();
$headScript->setContainer($headScriptContainer);
$html = $this->renderer->render($viewModel);
$css = $headlink->getContainer()->getArrayCopy();
$script = $headScript->getContainer()->getArrayCopy();
$return = ['html' => $html, 'css' => $this->getContainerSrc($css), 'js' => $this->getContainerSrc($script), 'editJs' => '', 'editCss' => '', 'displayName' => '', 'tooltip' => '', 'icon' => '', 'siteWide' => false, 'md5' => '', 'fromCache' => false, 'canCache' => false, 'pluginName' => $pluginName, 'pluginInstanceId' => $pluginInstanceId];
if (isset($this->config['rcmPlugin'][$pluginName]['display'])) {
$return['displayName'] = $this->config['rcmPlugin'][$pluginName]['display'];
}
if (isset($this->config['rcmPlugin'][$pluginName]['tooltip'])) {
$return['tooltip'] = $this->config['rcmPlugin'][$pluginName]['tooltip'];
}
if (isset($this->config['rcmPlugin'][$pluginName]['icon'])) {
$return['icon'] = $this->config['rcmPlugin'][$pluginName]['icon'];
}
if (isset($this->config['rcmPlugin'][$pluginName]['canCache'])) {
$return['canCache'] = $this->config['rcmPlugin'][$pluginName]['canCache'];
}
$headlink->setContainer($oldContainer);
$headScript->setContainer($oldScriptContainer);
return $return;
}
示例8: getMatchesFromInlineScript
/**
* Get rules and messages as matches from the inlineScript string
*
* @return array
*/
protected function getMatchesFromInlineScript()
{
/** @var $inlineScript \Zend\View\Helper\InlineScript */
$inlineScript = $this->view->plugin('inlineScript');
$inlineString = preg_replace('/(\\r\\n|\\r|\\n|\\t)+/', '', $inlineScript->toString());
if (preg_match('/\\$\\(\'form\\[name=\\"(?P<form>[a-z]*)"\\]\'\\)\\.validate\\((?P<options>.*)\\);}\\);/', $inlineString, $matches)) {
$options = json_decode($matches['options'], true);
$matches['rules'] = $options['rules'];
$matches['messages'] = $options['messages'];
return $matches;
}
return array();
}
示例9: renderFieldset
/** {@inheritdoc} */
public function renderFieldset(\Zend\View\Renderer\PhpRenderer $view, \Zend\Form\Fieldset $fieldset)
{
$output = '';
if ($fieldset->has('Packages')) {
$packages = $fieldset->get('Packages');
if ($packages->count()) {
$formRow = $view->plugin('FormRow');
$translatorEnabled = $formRow->isTranslatorEnabled();
$formRow->setTranslatorEnabled(false);
$output = "<div class='table'>\n";
foreach ($packages as $package) {
$output .= $view->formRow($package, 'append') . "\n\n";
}
$output .= "<span class='cell'></span>\n";
$output .= $view->formSubmit($fieldset->get('Submit')) . "\n";
$output .= "</div>\n";
$formRow->setTranslatorEnabled($translatorEnabled);
}
}
return $output;
}
示例10: testImageTagRenderedProperlyBasedUponDoctype
/**
* @group ZF-11483
*/
public function testImageTagRenderedProperlyBasedUponDoctype()
{
$this->testCaptchaIsRendered();
$view = new View();
$view->plugin('doctype')->setDoctype('XHTML1_STRICT');
$this->assertRegExp('#/>$#', $this->captcha->render($view));
$view->plugin('doctype')->setDoctype('HTML4_STRICT');
$this->assertRegExp('#[^/]>$#', $this->captcha->render($view));
}
示例11: testCharset
/**
* @issue ZF-7722
*/
public function testCharset()
{
$view = new View();
$view->plugin('doctype')->__invoke('HTML5');
$view->plugin('headMeta')->setCharset('utf-8');
$this->assertEquals('<meta charset="utf-8">', $view->plugin('headMeta')->toString());
$view->plugin('doctype')->__invoke('XHTML5');
$this->assertEquals('<meta charset="utf-8"/>', $view->plugin('headMeta')->toString());
}
示例12: testGetDocument
/**
* Test
*
* @return void
*/
public function testGetDocument()
{
$parent = new ViewModel();
$parent->setTemplate('layout');
$view = new View();
$renderer = Registry::get('Application')->getServiceManager()->get('Zend\\View\\Renderer\\PhpRenderer');
$view->setHelperPluginManager($renderer->getHelperPluginManager());
$view->plugin('view_model')->setRoot($parent);
$view->resolver()->addPath(__DIR__ . '/_files/views');
$this->object->setView($view);
$this->assertInstanceOf('Gc\\Document\\Model', $this->object->getDocument());
}
示例13: renderFieldset
/** {@inheritdoc} */
public function renderFieldset(\Zend\View\Renderer\PhpRenderer $view, \Zend\Form\Fieldset $fieldset)
{
if ($fieldset->getName() == 'Fields') {
// Labels (except "Category") are user defined and must not be translated.
$fieldset->get('TAG')->setLabel($view->translate('Category'));
$formRow = $view->plugin('FormRow');
$translatorEnabled = $formRow->isTranslatorEnabled();
$formRow->setTranslatorEnabled(false);
$output = parent::renderFieldset($view, $fieldset);
$formRow->setTranslatorEnabled($translatorEnabled);
} else {
$output = $this->renderFieldset($view, $this->get('Fields'));
$output .= "<div class='table'>\n";
$output .= "<span class='cell'></span>\n";
$output .= $view->formSubmit($fieldset->get('Submit')) . "\n";
$output .= "</div>\n";
}
return $output;
}
示例14: getFunctions
/**
* @inheritdoc
*/
public function getFunctions()
{
foreach ($this->viewHelpers['aliases'] as $alias => $factory) {
(yield new \Twig_SimpleFunction($alias, [$this->renderer->plugin($factory), '__invoke'], ['is_safe' => ['html']]));
}
}