@param PlatformContentItemDetailsEvent $event

@DI\Observe("administration_analytics_platform_content_item_details_portfolio")
344559
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();
    }
487811
public function onConsoleCommand(ConsoleCommandEvent $event): void
    {
        $command = $event->getCommand();

        Hub::getCurrent()
            ->configureScope(function (Scope $scope) use ($command): void {
                $scope->setTag('command', $command ? $command->getName() : 'N/A');
            });
    }
835741
public function handleAddImageToTemplate(AddImageToTemplateEvent $event)
    {
        /** @var Controller $controllerAdapter */
        $controllerAdapter = $this->framework->getAdapter(Controller::class);

        $controllerAdapter->addImageToTemplate(
            $event->getTemplate(),
            $event->getImageData(),
            $event->getMaxWidth(),
            $event->getLightboxId()
        );
    }
1301543
public function handlePersistStructureType(PersistEvent $event)
    {
        $document = $event->getDocument();

        if (!$this->supportsBehavior($document)) {
            return;
        }

        $structureMetadata = $this->inspector->getStructureMetadata($document);

        $structure = $document->getStructure();
        if ($structure instanceof ManagedStructure) {
            $structure->setStructureMetadata($structureMetadata);
        }
    }
926272
public function onView(GetResponseForControllerResultEvent $event)
    {
        if (!$this->eventRequestMatches($event)) {
            return;
        }
        $event->setResponse($this->responseTransformer->createResponseFromContent($event->getControllerResult()));
    }
1129564
public static function onApplicationStop(Event $event)
    {
        $container = $event->getTarget()->getContainer();
        $eventDispatcher = $container->has('event.dispatcher') ? $container->get('event.dispatcher') : null;

        foreach (array_keys($container->findTaggedServiceIds('bundle')) as $bundleId) {
            if (!$container->hasInstanceOf($bundleId)) {
                continue;
            }

            $bundle = $container->get($bundleId);
            $bundle->stop();

            if (null !== $eventDispatcher) {
                $eventDispatcher->dispatch(
                    sprintf('bundle.%s.stopped', $bundleId),
                    new BundleStopEvent($container->get($bundleId))
                );
            }
        }
    }
1307902
public function onAdminMatch(AdminMatchEvent $event): void
    {
        $pageLayoutTemplate = $event->getPageLayoutTemplate();
        if ($pageLayoutTemplate !== null) {
            return;
        }

        $currentRequest = $this->requestStack->getCurrentRequest();
        if (!$currentRequest instanceof Request) {
            return;
        }

        $siteAccess = $currentRequest->attributes->get('siteaccess')->name;
        if (!isset($this->groupsBySiteAccess[$siteAccess])) {
            return;
        }

        if (!in_array(EzPlatformAdminUiBundle::ADMIN_GROUP_NAME, $this->groupsBySiteAccess[$siteAccess], true)) {
            return;
        }

        $event->setPageLayoutTemplate($this->pageLayoutTemplate);
    }
436630
public function onPostSerialize(ObjectEvent $event)
    {
        $document = $event->getObject();
        $context = $event->getContext();

        if (!$document instanceof StructureBehavior) {
            return;
        }

        $visitor = $event->getVisitor();
        $structureMetadata = $this->inspector->getStructureMetadata($document);

        if ($structureMetadata) {
            $visitor->addData('template', $document->getStructureType());
            $visitor->addData('originTemplate', $document->getStructureType());
            $visitor->addData('internal', false);
            $visitor->addData(
                'localizedTemplate',
                $structureMetadata->getTitle(
                    $this->inspector->getLocale($document)
                )
            );

            if (false !== array_search('defaultPage', $context->attributes->get('groups')->getOrElse([]))) {
                $this->addStructureProperties($structureMetadata, $document, $visitor);
            }

            // create bread crumbs
            if (false !== array_search('breadcrumbPage', $context->attributes->get('groups')->getOrElse([]))) {
                $this->addBreadcrumb($document, $visitor);
            }
        }
    }
731520
public function onDisplayDesktopReservationAgenda(DisplayToolEvent $event)
    {
        $resourcesTypes = $this->em->getRepository('FormaLibreReservationBundle:ResourceType')->findAll();

        foreach ($resourcesTypes as $resourcesType) {
            foreach ($resourcesType->getResources() as $resource) {
                if (!$this->reservationManager->hasAccess($this->tokenStorage->getToken()->getUser(), $resource, ReservationController::SEE)) {
                    $resourcesType->removeResource($resource);
                }
            }
        }

        $event->setContent($this->templating->render('FormaLibreReservationBundle:tool:reservation_agenda.html.twig', ['resourcesType' => $resourcesTypes]));
    }
1325727
public function onDisplayWorkspaceAgenda(DisplayToolEvent $event)
    {
        $workspace = $event->getWorkspace();
        $editableWorkspace = $this->authorization->isGranted(['agenda_', 'edit'], $workspace);

        $content = $this->templating->render(
            'ClarolineAgendaBundle:tool:agenda.html.twig',
            [
                'workspace' => $workspace,
                'editableWorkspaces' => [$workspace->getUuid() => $editableWorkspace],
            ]
        );

        $event->setContent($content);
    }
152839
public function onKernelView(GetResponseForControllerResultEvent $event): void
    {
        $request = $event->getRequest();
        if ($request->isMethodSafe(false) || !($attributes = RequestAttributesExtractor::extractAttributes($request)) || !$attributes['persist']) {
            return;
        }

        $controllerResult = $event->getControllerResult();
        if (!$this->dataPersister->supports($controllerResult, $attributes)) {
            return;
        }

        switch ($request->getMethod()) {
            case 'PUT':
            case 'PATCH':
            case 'POST':
                $persistResult = $this->dataPersister->persist($controllerResult, $attributes);

                if (null === $persistResult) {
                    @trigger_error(sprintf('Returning void from %s::persist() is deprecated since API Platform 2.3 and will not be supported in API Platform 3, an object should always be returned.', DataPersisterInterface::class), E_USER_DEPRECATED);
                } else {
                    $controllerResult = $persistResult;
                    $event->setControllerResult($controllerResult);
                }

                if (null === $this->iriConverter) {
                    return;
                }

                $hasOutput = true;
                if (null !== $this->resourceMetadataFactory) {
                    $resourceMetadata = $this->resourceMetadataFactory->create($attributes['resource_class']);
                    $outputMetadata = $resourceMetadata->getOperationAttribute($attributes, 'output', ['class' => $attributes['resource_class']], true);
                    $hasOutput = \array_key_exists('class', $outputMetadata) && null !== $outputMetadata['class'] && $controllerResult instanceof $outputMetadata['class'];
                }

                if ($hasOutput) {
                    $request->attributes->set('_api_write_item_iri', $this->iriConverter->getIriFromItem($controllerResult));
                }
            break;
            case 'DELETE':
                $this->dataPersister->remove($controllerResult);
                $event->setControllerResult(null);
                break;
        }
    }
1058900
public function checkPermissionForProperties(BuildDataDefinitionEvent $event)
    {
        if (!$this->scopeDeterminator->currentScopeIsBackend()) {
            return;
        }

        $container          = $event->getContainer();
        $properties         = $container->getPropertiesDefinition();
        $palettesDefinition = $container->getPalettesDefinition();

        foreach ($palettesDefinition->getPalettes() as $palette) {
            foreach ($palette->getProperties() as $property) {
                if (!$properties->hasProperty($name = $property->getName())) {
                    // @codingStandardsIgnoreStart
                    @\trigger_error(
                        \sprintf(
                            'Warning: unknown property "%s" in palette: %s',
                            $name,
                            $palette->getName()
                        ),
                        E_USER_WARNING
                    );
                    // @codingStandardsIgnoreEnd
                    continue;
                }

                $this
                    ->getVisibilityConditionChain($property)
                    ->addCondition(new BooleanCondition(!$properties->getProperty($name)->isExcluded()));
            }
        }
    }
588009
public function onCoreController(FilterControllerEvent $event)
    {
        // do not capture admin cms urls
        if (!preg_match('/.*\/admin\/.*/', $event->getRequest()->getRequestUri())) {
            return;
        }

        if (!$this->tokenStorage->getToken()) {
            return;
        }

        $user = $this->tokenStorage->getToken()->getUser();
        if ($user instanceof UserInterface) {

            //here we can update the user as necessary
            if (method_exists($user, 'setLastActivity')) {
                try {
                    $user->setLastActivity(new \DateTime('now'));
                    $this->em->persist($user);
                    $this->em->flush($user);
                } catch (\Doctrine\ORM\ORMException $e) {
                    //do nothing, entity manager is closed
                }
            }
        }
    }
761496
public function onViewBeforeRender(Event $event)
    {
        /**
         * @var Container $container
         * @var Profiler  $profiler
         */
        $container = $event['view']->getPackage()->getContainer();
        $profiler  = $container->get('profiler');

        $name = $event['view']->getPackage()->name . '@' . $event['view']->getName();

        $profiler->mark(__FUNCTION__ . ' / ' . $name . ' (' . uniqid() . ')', [
            'tag' => 'package.process',
        ]);
    }
525505
public function onProductShow(ResourceControllerEvent $event): void
    {
        $product = $event->getSubject();
        if (!$product instanceof ProductInterface) {
            return;
        }

        $currentRequest = $this->requestStack->getCurrentRequest();
        if ($currentRequest instanceof Request) {
            $currentRequest->attributes->set('nglayouts_sylius_product', $product);
            // We set context here instead in a ContextProvider, since sylius.product.show
            // event happens too late, after onKernelRequest event has already been executed
            $this->context->set('sylius_product_id', (int) $product->getId());
        }
    }
485393
public function onDisplay(DisplayWidgetEvent $event)
    {
        if (!$this->authorization->isGranted('ROLE_USER')) {

            throw new AccessDeniedException();
        }

        $content = $this->templating->render(
            'ClarolineCoreBundle:Widget:desktopWidgetMyWorkspaces.html.twig',
            array()
        );
        $event->setContent($content);
        $event->stopPropagation();
    }
642972
public function onDisplayDesktop(DisplayToolEvent $event)
    {
        $subRequest = $this->container->get('request')->duplicate(array(), null, array("_controller" => 'FormaLibreBulletinBundle:Bulletin:index'));
        $response = $this->container->get('http_kernel')->handle($subRequest, HttpKernelInterface::SUB_REQUEST);

        $event->setContent($response->getContent());

    }