/**
  * @param PlatformContentItemDetailsEvent $event
  *
  * @DI\Observe("administration_analytics_platform_content_item_details_portfolio")
  */
 public function onPlatformContentItemDetailsPortfolio(PlatformContentItemDetailsEvent $event)
 {
     $this->entityManager->getFilters()->disable('softdeleteable');
     $countPortfolio = $this->portfolioManager->countAll();
     $countDeletedPortfolio = $this->portfolioManager->countAllDeleted();
     $countClosedPortfolio = 0;
     $countOpenPortfolio = 0;
     $countPrivatePortfolio = 0;
     $countPlatformPortfolio = 0;
     $countPortfolioByVisibilityStatuss = $this->portfolioManager->countAllByVisibilityStatus();
     foreach ($countPortfolioByVisibilityStatuss as $countPortfolioByVisibilityStatus) {
         switch ($countPortfolioByVisibilityStatus['visibility']) {
             case Portfolio::VISIBILITY_NOBODY:
                 $countClosedPortfolio = $countPortfolioByVisibilityStatus['number'];
                 break;
             case Portfolio::VISIBILITY_EVERYBODY:
                 $countOpenPortfolio = $countPortfolioByVisibilityStatus['number'];
                 break;
             case Portfolio::VISIBILITY_USER:
                 $countPrivatePortfolio = $countPortfolioByVisibilityStatus['number'];
                 break;
             case Portfolio::VISIBILITY_PLATFORM_USER:
                 $countPlatformPortfolio = $countPortfolioByVisibilityStatus['number'];
                 break;
             default:
                 throw new \Exception();
                 //not supposed to happen, but hey who knows ;-)
         }
     }
     $countPortfolioByVisibilityStatusGraphData = [['name' => 'closed_mode_portfolio', 'value' => $countClosedPortfolio], ['name' => 'open_mode_portfolio', 'value' => $countOpenPortfolio], ['name' => 'private_mode_portfolio', 'value' => $countPrivatePortfolio], ['name' => 'platform_mode_portfolio', 'value' => $countPlatformPortfolio]];
     $event->setContent($this->twig->render('IcapPortfolioBundle:analytics:platform_content_item_details.html.twig', ['countPortfolio' => $countPortfolio, 'countClosedPortfolio' => $countClosedPortfolio, 'countOpenPortfolio' => $countOpenPortfolio, 'countPrivatePortfolio' => $countPrivatePortfolio, 'countPlatformPortfolio' => $countPlatformPortfolio, 'countDeletedPortfolio' => $countDeletedPortfolio, 'portfolioRepartitionStatuss' => $countPortfolioByVisibilityStatusGraphData]));
     $event->stopPropagation();
 }
Пример #2
0
 /**
  * @param Portfolio $portfolio
  *
  * @return bool True on successfull processing, false otherwise
  */
 public function handleGuides(Portfolio $portfolio)
 {
     $originalPortfolioGuides = $portfolio->getPortfolioGuides();
     $form = $this->getGuidesForm($portfolio);
     $request = $this->requestStack->getCurrentRequest();
     if ($request->isMethod('POST')) {
         $form->submit($request);
         if ($form->isValid()) {
             $this->portfolioManager->updateGuides($portfolio, $originalPortfolioGuides);
             return true;
         }
     }
     return false;
 }