public function testRenderResponseWithTemplatingEngine()
 {
     $engine = $this->getEngineMock('template.php', true);
     $container = $this->getContainerMock(array('engine' => $engine));
     $delegatingEngine = new DelegatingEngine($container, array('engine'));
     $this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\Response', $delegatingEngine->renderResponse('template.php', array('foo' => 'bar')));
 }
Esempio n. 2
0
 /**
  * Renders menu
  *
  * @param ItemInterface $item
  * @param array         $options
  *
  * @return string
  */
 public function render(ItemInterface $item, array $options = array())
 {
     $options = array_merge($this->defaultOptions, $options);
     if ($options['clear_matcher']) {
         $this->matcher->clear();
     }
     //render html
     $html = $this->engine->render($options['template'], array('item' => $item, 'options' => $options, 'matcher' => $this->matcher));
     return $html;
 }
 /**
  * @param \FSi\Bundle\AdminBundle\Admin\Context\ContextManager $manager
  * @param \FSi\Bundle\AdminBundle\Admin\Display\Element $element
  * @param \FSi\Bundle\AdminBundle\Admin\Display\Context\DisplayContext $context
  * @param \Symfony\Component\HttpFoundation\Request $request
  * @param \Symfony\Bundle\FrameworkBundle\Templating\DelegatingEngine $templating
  * @param \Symfony\Component\HttpFoundation\Response $response
  */
 function it_render_template_from_element_in_display_action($manager, $element, $context, $request, $templating, $response)
 {
     $manager->createContext('fsi_admin_display', $element)->willReturn($context);
     $context->handleRequest($request)->willReturn(null);
     $context->hasTemplateName()->willReturn(true);
     $context->getTemplateName()->willReturn('custom_template');
     $context->getData()->willReturn(array());
     $templating->renderResponse('custom_template', array(), null)->willReturn($response);
     $this->displayAction($element, $request)->shouldReturn($response);
 }
Esempio n. 4
0
 /**
  * Renders menu
  *
  * @param ItemInterface $item
  * @param array         $options
  *
  * @return string
  */
 public function render(ItemInterface $item, array $options = array())
 {
     $options = array_merge($this->defaultOptions, $options);
     if ($options['clear_matcher']) {
         $this->matcher->clear();
     }
     $manipulator = new MenuManipulator();
     if ($options["menu"] == "admin") {
         //render html
         $html = $this->engine->render("MauticCoreBundle:Menu:admin.html.php", array("item" => $item, "options" => $options, "matcher" => $this->matcher));
     } else {
         //render html
         $html = $this->engine->render("MauticCoreBundle:Menu:main.html.php", array("item" => $item, "options" => $options, "matcher" => $this->matcher));
     }
     return $html;
 }
Esempio n. 5
0
 /**
  * Send invite email to new user
  *
  * @param User   $user
  * @param string $plainPassword
  *
  * @throws \RuntimeException
  */
 protected function sendInviteMail(User $user, $plainPassword)
 {
     if (in_array(null, [$this->cm, $this->mailer, $this->templating], true)) {
         throw new \RuntimeException('Unable to send invitation email, unmet dependencies detected.');
     }
     $senderEmail = $this->cm->get('oro_notification.email_notification_sender_email');
     $senderName = $this->cm->get('oro_notification.email_notification_sender_name');
     $message = \Swift_Message::newInstance()->setSubject('Invite user')->setFrom($senderEmail, $senderName)->setTo($user->getEmail())->setBody($this->templating->render('OroUserBundle:Mail:invite.html.twig', ['user' => $user, 'password' => $plainPassword]), 'text/html');
     $this->mailer->send($message);
 }
Esempio n. 6
0
 /**
  * Use a template as the body
  *
  * @param string $template
  * @param array  $vars
  * @param bool   $returnContent
  * @param null   $charset
  *
  * @return void
  */
 public function setTemplate($template, $vars = array(), $returnContent = false, $charset = null)
 {
     if ($this->templating == null) {
         $this->templating = $this->factory->getTemplating();
     }
     $content = $this->templating->renderResponse($template, $vars)->getContent();
     unset($vars);
     if ($returnContent) {
         return $content;
     }
     $this->setBody($content, 'text/html', $charset);
     unset($content);
 }
Esempio n. 7
0
 /**
  * @param $c
  * @param $buttonCount
  *
  * @return string
  */
 public function buildCustom($c, $buttonCount)
 {
     $buttons = '';
     //Wrap links in a tag
     if ($this->groupType == 'dropdown' || $this->groupType == 'button-dropdown' && $buttonCount > 0) {
         $this->wrapOpeningTag = "<li>\n";
         $this->wrapClosingTag = "</li>\n";
     }
     if (isset($c['confirm'])) {
         if ($this->groupType == 'group' || $this->groupType == 'button-dropdown' && $buttonCount === 0) {
             if (isset($c['confirm']['btnClass']) && !strstr($c['confirm']['btnClass'], 'btn-')) {
                 $c['confirm']['btnClass'] .= ' btn btn-default';
             } elseif (!isset($c['confirm']['btnClass'])) {
                 $c['confirm']['btnClass'] = 'btn btn-default';
             }
         } elseif (in_array($this->groupType, array('button-dropdown', 'dropdown'))) {
             if (!isset($c['confirm']['btnClass'])) {
                 $c['confirm']['btnClass'] = '';
             } elseif ($this->groupType == 'button-dropdown') {
                 $search = array('btn-default', 'btn-primary', 'btn-success', 'btn-info', 'btn-warning', 'btn-danger', 'btn');
                 $c['confirm']['btnClass'] = str_replace($search, '', $c['attr']['class']);
             }
         }
         $buttons .= $this->wrapOpeningTag . $this->templating->render('MauticCoreBundle:Helper:confirm.html.php', $c['confirm']) . "{$this->wrapClosingTag}\n";
     } else {
         $attr = $this->menuLink;
         if (!isset($c['attr'])) {
             $c['attr'] = array();
         }
         if (isset($c['btnClass'])) {
             $c['attr']['class'] = $c['btnClass'];
         }
         if ($this->groupType == 'group' || $this->groupType == 'button-dropdown' && $buttonCount === 0) {
             if (!isset($c['attr']['class'])) {
                 $c['attr']['class'] = 'btn btn-default';
             } elseif (!strstr($c['attr']['class'], 'btn-')) {
                 $c['attr']['class'] .= ' btn btn-default';
             }
         } elseif (($this->groupType == 'dropdown' || $this->groupType == 'button-dropdown' && $buttonCount > 0) && isset($c['attr']['class'])) {
             // Remove btn classes
             $search = array('btn-default', 'btn-primary', 'btn-success', 'btn-info', 'btn-warning', 'btn-danger', 'btn');
             $c['attr']['class'] = str_replace($search, '', $c['attr']['class']);
         }
         if (!isset($c['attr']['data-toggle'])) {
             $c['attr']['data-toggle'] = 'ajax';
         }
         $tooltipAttr = '';
         if (isset($c['tooltip'])) {
             $tooltipAttr .= ' data-toggle="tooltip"';
             if (is_array($c['tooltip'])) {
                 foreach ($c['tooltip'] as $k => $v) {
                     if ($k == 'title') {
                         $v = $this->translator->trans($v);
                     }
                     $tooltipAttr .= " {$k}=" . '"' . $v . '"';
                 }
             } else {
                 $tooltipAttr .= ' title="' . $this->translator->trans($c['tooltip']) . '" data-placement="left"';
             }
         }
         foreach ($c['attr'] as $k => $v) {
             $attr .= " {$k}=" . '"' . $v . '"';
         }
         $buttonContent = isset($c['iconClass']) ? '<i class="' . $c['iconClass'] . '"></i> ' : '';
         if (!empty($c['btnText'])) {
             $buttonContent .= $this->translator->trans($c['btnText']);
         }
         $buttons .= "{$this->wrapOpeningTag}<a{$attr}><span{$tooltipAttr}>{$buttonContent}</span></a>{$this->wrapClosingTag}\n";
     }
     return $buttons;
 }
 /**
  * @param string $view
  * @param array $parameters
  * @param Response $response
  * @return Response|void
  */
 public function renderResponse($view, array $parameters = array(), Response $response = null)
 {
     $event = new DelegatingEngineEvent($view, $parameters, $response, $this->getRequest());
     $this->getEventDispatcher()->dispatch(DelegatingEngineEvents::PRE_RENDER, $event);
     return parent::renderResponse($event->getView(), $event->getParameters(), $event->getResponse());
 }