本文整理汇总了PHP中Zend\View\Renderer\PhpRenderer::setResolver方法的典型用法代码示例。如果您正苦于以下问题:PHP PhpRenderer::setResolver方法的具体用法?PHP PhpRenderer::setResolver怎么用?PHP PhpRenderer::setResolver使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\View\Renderer\PhpRenderer
的用法示例。
在下文中一共展示了PhpRenderer::setResolver方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: PdfAction
public function PdfAction()
{
$pdf = new TCPDF('L');
$pdf->SetPrintHeader(true);
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
// set margins
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
// set auto page breaks
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
// set image scale factor
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
// set some language-dependent strings (optional)
if (@file_exists(dirname(__FILE__) . '/lang/eng.php')) {
require_once dirname(__FILE__) . '/lang/eng.php';
$pdf->setLanguageArray($l);
}
// set font
$pdf->SetFont('helvetica', '', 8);
// add a page
$pdf->AddPage();
//get report data into $data variable
$project = $this->getServiceLocator()->get('ProjectTable');
$data = $project->getWsr();
$view = new PhpRenderer();
$resolver = new TemplateMapResolver();
//set the path of the pdf.phtml file
$resolver->setMap(array('PDFTemplate' => '/var/www/html/WSRAutomation/module/Application/view/application/index/pdf.phtml'));
$view->setResolver($resolver);
$viewModel = new ViewModel();
$viewModel->setTemplate('PDFTemplate')->setVariables(array('projects' => $data, 'view' => 'pdf'));
$html = $view->render($viewModel);
$pdf->writeHTML($html, true, 0, true, 0);
$pdf->Output('WsrReport.pdf', 'I');
}
示例2: 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;
}
示例3: setUp
public function setUp()
{
$this->formConfig = ['template' => 't4web-form-renderer/element/form', 'children' => ['name' => ['template' => 't4web-form-renderer/element/text', 'variables' => ['label' => 'Name', 'placeholder' => 'Enter name']], 'link' => ['template' => 't4web-form-renderer/element/text', 'variables' => ['label' => 'Link', 'placeholder' => 'Enter link']]], 'variables' => ['action' => '/admin/news/create', 'cancelLink' => '/admin/list']];
$this->renderer = new PhpRenderer();
$stack = new Resolver\TemplatePathStack(array('script_paths' => array(dirname(dirname(__DIR__)) . '/view')));
$this->renderer->setResolver($stack);
}
示例4: __construct
protected function __construct($directory)
{
$this->directory = $directory;
$this->phpRenderer = new PhpRenderer();
$resolver = new AggregateResolver();
$this->phpRenderer->setResolver($resolver);
$path = Module::getBaseDirectory() . $this->directory;
$stack = new TemplatePathStack(array('script_paths' => array($path)));
$resolver->attach($stack);
}
示例5: __invoke
/**
* @param ContainerInterface $container
* @returns ZendViewRenderer
*/
public function __invoke(ContainerInterface $container)
{
$config = $container->has('config') ? $container->get('config') : [];
$config = isset($config['templates']) ? $config['templates'] : [];
// Configuration
$resolver = new Resolver\AggregateResolver();
$resolver->attach(new Resolver\TemplateMapResolver(isset($config['map']) ? $config['map'] : []), 100);
// Create the renderer
$renderer = new PhpRenderer();
$renderer->setResolver($resolver);
$manager = $container->has(HelperPluginManager::class) ? $container->get(HelperPluginManager::class) : new HelperPluginManager();
// Inject helpers
$this->injectHelpers($renderer, $manager);
// Initialize renderer for HelperPluginManager
$manager->setRenderer($renderer);
// Inject renderer
$view = new ZendViewRenderer($renderer, isset($config['layout']) ? $config['layout'] : null);
// Add template paths
$allPaths = isset($config['paths']) && is_array($config['paths']) ? $config['paths'] : [];
foreach ($allPaths as $namespace => $paths) {
$namespace = is_numeric($namespace) ? null : $namespace;
foreach ((array) $paths as $path) {
$view->addPath($path, $namespace);
}
}
return $view;
}
示例6: __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;
}
示例7: getTestRenderer
/**
* @return PhpRenderer
*/
public function getTestRenderer()
{
$resolver = new TemplatePathStack();
$resolver->addPath(__DIR__ . '/../views');
$renderer = new PhpRenderer();
$renderer->setResolver($resolver);
return $renderer;
}
示例8: setUp
public function setUp()
{
$this->transport = new MockTransport();
$config = (include __DIR__ . '/../../config/module.config.php');
$renderer = new PhpRenderer();
$renderer->setResolver(new TemplatePathStack($config['view_manager']['template_path_stack']));
$this->mailService = new MailService(new Message(), $this->transport, $renderer);
}
示例9: setUp
public function setUp()
{
$config = (include __DIR__ . '/../../../config/module.config.php');
$renderer = new PhpRenderer();
$renderer->setResolver(new TemplateMapResolver($config['view_manager']['template_map']));
$router = TreeRouteStack::factory($config['router']);
$this->helper = new QrCodeHelper($renderer, $router, new QrCodeServiceMock('foobar'));
}
示例10: autocompleteAction
public function autocompleteAction(Request $request, Response $response = null)
{
$serviceManager = $this->getServiceLocator();
$console = $serviceManager->get('console');
$resolver = $serviceManager->get('ViewResolver');
$render = new PhpRenderer();
$render->setResolver($resolver);
$console->write($render->render('client/manual/autocomplete'));
}
示例11: getContent
public function getContent()
{
$info = new \SplFileInfo($this->file);
$renderer = new PhpRenderer();
$stack = new TemplatePathStack();
$stack->addPath($info->getPath());
$stack->setDefaultSuffix(pathinfo($this->file, PATHINFO_EXTENSION));
$renderer->setResolver($stack);
return $renderer->render($info->getBasename());
}
示例12: renderTemplatePath
protected function renderTemplatePath($strPath, $arrVariables)
{
$view = new PhpRenderer();
$resolver = new TemplateMapResolver();
$resolver->setMap(array('mailTemplate' => __DIR__ . '/../../../' . $strPath));
$view->setResolver($resolver);
$viewModel = new ViewModel();
$viewModel->setTemplate('mailTemplate')->setVariables($arrVariables);
return $view->render($viewModel);
}
示例13: 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;
}
示例14: render
public function render()
{
$renderer = new PhpRenderer();
$resolver = new Resolver\AggregateResolver();
$renderer->setResolver($resolver);
$map = new Resolver\TemplateMapResolver(array(static::getTemplate() => __DIR__ . '/view/' . static::getTemplate() . '.phtml'));
$resolver->attach($map);
// this will be consulted first
return $renderer->render($this);
}
示例15: setUp
/**
* Sets up the fixture, for example, open a network connection.
* This method is called before a test is executed.
*
* @access protected
*/
protected function setUp()
{
$resolver = new Resolver\TemplatePathStack(array('script_paths' => array(__DIR__ . '/_files/scripts')));
$view = new View();
$view->setResolver($resolver);
Helper\PaginationControl::setDefaultViewPartial(null);
$this->_viewHelper = new Helper\PaginationControl();
$this->_viewHelper->setView($view);
$this->_paginator = Paginator\Paginator::factory(range(1, 101));
}