コード例 #1
0
ファイル: ViewCssListener.php プロジェクト: global01/victoire
 /**
  * Generate cssHash and css file for current View if cssHash has not been set yet.
  *
  * @param PageRenderEvent $event
  *
  * @throws \Exception
  */
 public function onRenderPage(PageRenderEvent $event)
 {
     $currentView = $event->getCurrentView();
     if ($currentView instanceof VirtualBusinessPage) {
         $currentView->setCssHash($currentView->getTemplate()->getCssHash());
     } elseif (!($viewHash = $currentView->getCssHash())) {
         $currentView->changeCssHash();
         $this->entityManager->persist($currentView);
         $this->entityManager->flush($currentView);
         $widgetRepo = $this->entityManager->getRepository('Victoire\\Bundle\\WidgetBundle\\Entity\\Widget');
         $this->widgetMapBuilder->build($currentView);
         $widgets = $widgetRepo->findAllWidgetsForView($currentView);
         $this->viewCssBuilder->generateViewCss($currentView, $widgets);
     }
 }
コード例 #2
0
ファイル: ViewCssListener.php プロジェクト: victoire/victoire
 /**
  * Generate cssHash and css file for current View if cssHash has not been set yet or is not up to date.
  *
  * @param PageRenderEvent $event
  *
  * @throws \Exception
  */
 public function onRenderPage(PageRenderEvent $event)
 {
     $currentView = $event->getCurrentView();
     if ($currentView instanceof VirtualBusinessPage) {
         $currentView->setCssHash($currentView->getTemplate()->getCssHash());
     } elseif (!$currentView->getCssHash() || !$currentView->isCssUpToDate()) {
         //Get View's widgets
         $widgetRepo = $this->entityManager->getRepository('Victoire\\Bundle\\WidgetBundle\\Entity\\Widget');
         $this->widgetMapBuilder->build($currentView);
         $widgets = $widgetRepo->findAllWidgetsForView($currentView);
         //Generate CSS file and set View's CSS as up to date
         $oldHash = $currentView->getCssHash();
         $currentView->changeCssHash();
         $this->viewCssBuilder->updateViewCss($oldHash, $currentView, $widgets);
         $currentView->setCssUpToDate(true);
         $this->entityManager->persist($currentView);
         $this->entityManager->flush($currentView);
     }
 }