Beispiel #1
0
 /**
  * @param Message $message
  * @return Message
  */
 public function render(Message $message)
 {
     $viewModel = new ViewModel($this->variables);
     $viewModel->setTemplate($this->template);
     $helperPluginManager = $this->renderer->getHelperPluginManager();
     /** @var HeadTitle $helper */
     $helper = $helperPluginManager->get('HeadTitle');
     // replace headTitle
     $headTitle = new HeadTitle();
     $headTitle->setAutoEscape(false);
     $helperPluginManager->setAllowOverride(true);
     $helperPluginManager->setService('HeadTitle', $headTitle);
     if (!$message->getBody()) {
         $message->setBody(new MimeMessage());
     }
     $text = new Part($this->renderer->render($viewModel));
     $text->charset = 'UTF-8';
     $text->boundary = $message->getBody()->getMime()->boundary();
     $text->encoding = Mime::ENCODING_BASE64;
     $text->type = Mime::TYPE_HTML;
     $message->getBody()->addPart($text);
     $message->setSubject($headTitle->renderTitle());
     // hack for ZF
     $message->setBody($message->getBody());
     // restore original helper
     $helperPluginManager->setService('HeadTitle', $helper);
     return $message;
 }
Beispiel #2
0
 protected function setUp()
 {
     $this->view = new PhpRenderer();
     $this->view->getHelperPluginManager()->get('basePath')->setBasePath('/');
     $this->helper = new Resize();
     $this->helper->setView($this->view);
 }
Beispiel #3
0
 /**
  * 
  * @return \Zend\View\Renderer\PhpRenderer
  */
 public function getRenderer()
 {
     if ($this->renderer === null) {
         $renderer = new PhpRenderer();
         // register view helpers
         $formHelperConfig = new ZendFormHelperConfig();
         $formHelperConfig->configureServiceManager($renderer->getHelperPluginManager());
         // register view helpers
         $formHelperConfig = new FormHelperConfig();
         $formHelperConfig->configureServiceManager($renderer->getHelperPluginManager());
         // set base path
         $path = $this->templatePath ?: __DIR__ . '/view/scripts';
         $renderer->resolver()->addPath($path);
         $this->setRenderer($renderer);
     }
     return $this->renderer;
 }
Beispiel #4
0
 public function testEvents()
 {
     $application = $this->services->get('application');
     $application->bootstrap();
     $events = new Events();
     $renderer = new PhpRenderer();
     $renderer->getHelperPluginManager()->setServiceLocator($this->services);
     $events->setView($renderer);
     $eventManager = $application->getEventManager();
     $events($eventManager);
 }
 public function getHTML()
 {
     $this->checkForGetHTMLZendDependencies();
     $html = null;
     $renderer = new PhpRenderer();
     $formHelperConfig = new \Zend\Form\View\HelperConfig();
     $formHelperConfig->configureServiceManager($renderer->getHelperPluginManager());
     $formRenderer = new \Zend\Form\View\Helper\Form();
     $html .= $formRenderer->openTag($this->form);
     $formRow = new \Zend\Form\View\Helper\FormRow();
     $formRow->setView($renderer);
     foreach ($this->form->getElements() as $key => $element) {
         $html .= '<div id="' . $key . '" class="element">';
         $html .= $formRow->render($element);
         $html .= '</div>' . PHP_EOL;
     }
     $html .= $formRenderer->closeTag();
     return $html;
 }
 public static function loadControler($template)
 {
     global $view;
     $template_name = ucfirst(str_replace('.php', '', basename($template)));
     $template_name = ucwords(str_replace('-', ' ', $template_name));
     $template_name = str_replace(' ', '', $template_name);
     $controller_name = 'Bundle\\FrontBundle\\Controller\\' . $template_name . 'Controller';
     $render = new PhpRenderer();
     $plugins = $render->getHelperPluginManager();
     $config = new HelperConfig();
     $config->configureServiceManager($plugins);
     if (class_exists($controller_name)) {
         $controller = new $controller_name();
         $vars = $controller->init();
         $vars['render'] = $render;
         $view = new ViewModel($vars);
     }
     return $template;
 }
Beispiel #7
0
 /**
  * Init renderer object
  */
 protected function initRenderer()
 {
     $renderer = new PhpRenderer();
     $plugins = $renderer->getHelperPluginManager();
     $config = new \Zend\Form\View\HelperConfig();
     $config->configureServiceManager($plugins);
     $resolver = new Resolver\AggregateResolver();
     $map = new Resolver\TemplateMapResolver($this->getTable()->getOptions()->getTemplateMap());
     $resolver->attach($map);
     $renderer->setResolver($resolver);
     $this->renderer = $renderer;
 }