示例#1
0
 /**
  * Create an instance of RendererEvent.
  *
  * @param mixed $target
  * @param mixed $arguments
  */
 public function __construct($target, $arguments = null)
 {
     parent::__construct($target, $arguments);
     $this->render = null;
     if (is_array($arguments)) {
         $this->renderer =& $arguments[0];
         $this->render =& $arguments[1];
     } else {
         $this->renderer =& $arguments;
     }
 }
 /**
  * Occurs on rest.controller.classcontentcontroller.getAction.postcall events.
  *
  * @param Event $event
  */
 public function onPostCall(Event $event)
 {
     $response = $event->getResponse();
     if ($response->headers->get('content-type') === 'text/html') {
         return;
     }
     $application = $event->getApplication();
     $renderer = $application->getRenderer();
     $content = json_decode($response->getContent());
     $result = false;
     if ($content instanceof \StdClass) {
         if (isset($content->type) && isset($content->parameters)) {
             if (isset($content->parameters->rendermode)) {
                 $result = true;
             }
         }
     }
     if (!$result) {
         return;
     }
     $rendermodeParam = $content->parameters->rendermode;
     $classname = AbstractClassContent::getClassnameByContentType($content->type);
     $modes = ['default' => 'Default mode'];
     foreach ($renderer->getAvailableRenderMode(new $classname()) as $mode) {
         $modes[$mode] = ucfirst(str_replace('_', ' ', $mode));
     }
     $rendermodeParam->options = $modes;
     $response->setContent(json_encode($content));
 }
示例#3
0
 /**
  * Occur on nestednode.page.preupdate events and nestednode.section.preupdate.
  *
  * @access public
  *
  * @param Event $event
  */
 public function onFlushPage(Event $event)
 {
     $uow = $this->entityManager->getUnitOfWork();
     $page = $event->getTarget();
     if ($uow->isScheduledForInsert($page) && $page->getParent() !== null && $page->getState() < 4) {
         self::setSectionHasChildren($page->getParent()->getSection(), +1);
     }
 }