Inheritance: extends Frontend\Core\Engine\Base\Object
Ejemplo n.º 1
0
 /**
  * Parse a widget straight from the template, rather than adding it through pages.
  *    syntax: {{ parsewidget($module, $action, $id) }}
  *
  * @internal if your widget outputs random data you should cache it inside the widget
  * Fork checks the output and if the output of the widget is random it will loop until the random data
  * is the same as in the previous iteration
  *
  * @param string $module The module whose module we want to execute.
  * @param string $action The action to execute.
  * @param string $id     The widget id (saved in data-column).
  *
  * @return null|string
  * @throws Exception
  */
 public static function parseWidget($module, $action, $id = null)
 {
     // create new widget instance and return parsed content
     $extra = FrontendBlockWidget::getForId(FrontendModel::get('kernel'), $module, $action, $id);
     // set parseWidget because we will need it to skip setting headers in the display
     FrontendModel::getContainer()->set('parseWidget', true);
     try {
         $extra->execute();
         $content = $extra->getContent();
         FrontendModel::getContainer()->set('parseWidget', null);
         return $content;
     } catch (Exception $e) {
         // if we are debugging, we want to see the exception
         if (FrontendModel::getContainer()->getParameter('kernel.debug')) {
             throw $e;
         }
         return;
     }
 }
Ejemplo n.º 2
0
 /**
  * Parse a widget straight from the template, rather than adding it through pages.
  *
  * @internal if your widget outputs random data you should cache it inside the widget
  * Fork checks the output and if the output of the widget is random it will loop until the random data
  * is the same as in the previous iteration
  * @param string $var    The variable.
  * @param string $module The module whose module we want to execute.
  * @param string $action The action to execute.
  * @param string $id     The widget id (saved in data-column).
  * @return string|null
  */
 public static function parseWidget($var, $module, $action, $id = null)
 {
     $data = $id !== null ? serialize(array('id' => $id)) : null;
     // create new widget instance and return parsed content
     $extra = new FrontendBlockWidget(Model::get('kernel'), $module, $action, $data);
     // set parseWidget because we will need it to skip setting headers in the display
     Model::getContainer()->set('parseWidget', true);
     try {
         $extra->execute();
         $content = $extra->getContent();
         Model::getContainer()->set('parseWidget', null);
         return $content;
     } catch (Exception $e) {
         // if we are debugging, we want to see the exception
         if (Model::getContainer()->getParameter('kernel.debug')) {
             throw $e;
         }
         return null;
     }
 }