@DI\Observe("open_tool_desktop_parameters")

@param DisplayToolEvent $event
439769
public function onDisplayDesktopParameters(DisplayToolEvent $event)
    {
        $user = $this->tokenStorage->getToken()->getUser();

        if ('anon.' === $user) {
            throw new AccessDeniedException();
        }
        $toolsRolesConfig = $this->toolManager->getUserDesktopToolsConfiguration($user);
        $desktopTools = $this->finder->get(Tool::class)->find(
            ['isDisplayableInDesktop' => true],
            ['property' => 'name', 'direction' => 1]
        );
        $tools = [];

        foreach ($desktopTools as $desktopTool) {
            $toolName = $desktopTool->getName();

            if (!in_array($toolName, ToolsOptions::EXCLUDED_TOOLS)) {
                $tools[] = $desktopTool;
            }
        }
        $orderedTools = $this->toolManager->computeUserOrderedTools($user, $toolsRolesConfig);
        $toolsConfig = [];

        foreach ($orderedTools as $orderedTool) {
            $toolName = $orderedTool->getTool()->getName();
            $toolsConfig[$toolName] = [
                'visible' => $orderedTool->isVisibleInDesktop(),
                'locked' => $orderedTool->isLocked(),
            ];
        }

        $event->setContent(
            $this->templating->render(
                'ClarolineCoreBundle:tool\desktop\parameters:parameters.html.twig',
                [
                    'tools' => array_map(function (Tool $tool) {
                        return $this->serializer->serialize($tool);
                    }, $tools),
                    'toolsConfig' => 0 < count($toolsConfig) ? $toolsConfig : new \stdClass(),
                ]
            )
        );
    }
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();
    }
457110
public function prepareGlobalAllButton(ActionEvent $event)
    {
        if (!$this->scopeDeterminator->currentScopeIsBackend() || ('showAll' !== $event->getAction()->getName())) {
            return;
        }

        $dataDefinition = $event->getEnvironment()->getDataDefinition();
        $backendView    = $dataDefinition->getDefinition(Contao2BackendViewDefinitionInterface::NAME);
        $globalCommands = $backendView->getGlobalCommands();

        if ($globalCommands->hasCommandNamed('all')) {
            $allCommand = $globalCommands->getCommandNamed('all');

            $parameters = $allCommand->getParameters();
            $parameters->offsetSet('select', 'models');
        }
    }
1312280
function showTooltipBind() {
              if(hasEnableExp && !scope.$eval(attrs[prefix+'Enable'])) {
                return;
              }

              prepareTooltip();

              if ( ttScope.popupDelay ) {
                // Do nothing if the tooltip was already scheduled to pop-up.
                // This happens if show is triggered multiple times before any hide is triggered.
                if (!popupTimeout) {
                  popupTimeout = $timeout( show, ttScope.popupDelay, false );
                  popupTimeout.then(function(reposition){reposition();});
                }
              } else {
                show()();
              }
            }
768940
public function onKernelRequest(GetResponseEvent $event): void
    {
        $request = $event->getRequest();
        if (
            'html' !== $request->getRequestFormat('') ||
            !($request->attributes->has('_api_resource_class') || $request->attributes->getBoolean('_api_respond', false))
        ) {
            return;
        }

        $request->attributes->set('_controller', 'api_platform.swagger.action.ui');
    }
672642
public function handleFrontendEditingInListRendering(RenderItemListEvent $event): void
    {
        $caller = $event->getCaller();
        if (!($caller instanceof HybridList)) {
            return;
        }

        $page    = null;
        $enabled = (bool) $caller->metamodel_fe_editing;
        if ($enabled) {
            $page    = $this->getPageDetails($caller->metamodel_fe_editing_page);
            $enabled = (null !== $page);

            $view = $event->getList()->getView();

            $view->set(self::FRONTEND_EDITING_PAGE, $page);
            $view->set(self::FRONTEND_EDITING_ENABLED_FLAG, $enabled);
        }

        if ($enabled) {
            $tableName  = $this->factory->translateIdToMetaModelName($caller->metamodel);
            $definition = $this->frontendEditor->createDcGeneral($tableName)->getDataDefinition();
            $enabled    = $definition->getBasicDefinition()->isCreatable();

            if ($enabled) {
                $url = $this->generateAddUrl($page);

                $caller->Template->addUrl      = $url;
                $caller->Template->addNewLabel = $this->translateLabel('metamodel_add_item', $tableName);
                $event->getTemplate()->addUrl  = $url;
            }
        }

        $event->getTemplate()->editEnable = $caller->Template->editEnable = $enabled;
    }
218945
public function onWorkspaceToolCopy(WorkspaceCopyToolEvent $event)
    {
        $oldWs = $event->getOldWorkspace();
        $workspace = $event->getNewWorkspace();

        $planned = $this->finder->fetch(PlannedNotification::class, ['workspace' => $oldWs->getUuid()]);
        $oldMessages = $this->finder->fetch(Message::class, ['workspace' => $oldWs->getUuid()]);
        $newNotifs = [];

        foreach ($planned as $old) {
            $new = $this->crud->copy($old, [Options::GENERATE_UUID]);
            $new->setWorkspace($workspace);
            $new->emptyRoles();

            foreach ($old->getRoles() as $role) {
                foreach ($workspace->getRoles() as $wsRole) {
                    if ($wsRole->getTranslationKey() === $role->getTranslationKey()) {
                        $new->addRole($wsRole);
                    }
                }
            }
            $newNotifs[$old->getId()] = $new;
            $this->om->persist($new);
        }

        foreach ($oldMessages as $old) {
            $new = $this->crud->copy($old, [Options::GENERATE_UUID]);
            $new->setWorkspace($workspace);
            $new->emptyNotifications();

            foreach ($old->getNotifications() as $oldNotification) {
                if (isset($newNotifs[$oldNotification->getId()])) {
                    $new->addNotification($newNotifs[$oldNotification->getId()]);
                }
            }

            $this->om->persist($new);
        }

        $this->om->flush();
    }
887133
public function onDisplayWorkspace(DisplayToolEvent $event)
    {
        $workspace = $event->getWorkspace();

        $content = $this->templating->render(
            'ClarolineCoreBundle:tool:resources.html.twig', [
                'workspace' => $workspace,
                'context' => [
                    'type' => Widget::CONTEXT_WORKSPACE,
                    'data' => $this->serializer->serialize($workspace),
                ],
                'root' => $this->serializer->serialize(
                    $this->resourceRepository->findWorkspaceRoot($workspace)
                ),
            ]
        );

        $event->setContent($content);
        $event->stopPropagation();
    }
70025
public function open(OpenResourceEvent $event)
    {
        $text = $event->getResource();
        $content = $this->templating->render(
            'ClarolineCoreBundle:text:index.html.twig',
            [
                'text' => $text,
                '_resource' => $text,
            ]
        );

        $event->setResponse(new Response($content));
        $event->stopPropagation();
    }
1129097
public function postBuildView(DataSourceEvent\ViewEventArgs $event)
    {
        $datasource = $event->getDataSource();
        $datasourceName = $datasource->getName();
        $view = $event->getView();
        $parameters = $view->getParameters();
        $maxresults = $datasource->getMaxResults();

        if ($maxresults == 0) {
            $all = 1;
            $page = 1;
        } else {
            $all = (int) ceil(count($datasource->getResult())/$maxresults);
            $current = $datasource->getFirstResult();
            $page = (int) floor($current/$maxresults) + 1;
        }

        unset($parameters[$datasourceName][PaginationExtension::PARAMETER_PAGE]);
        $pages = [];

        for ($i = 1; $i <= $all; $i++) {
            if ($i > 1) {
                $parameters[$datasourceName][PaginationExtension::PARAMETER_PAGE] = $i;
            }

            $pages[$i] = $parameters;
        }

        $view->setAttribute('max_results', $maxresults);
        $view->setAttribute('page', $page);
        $view->setAttribute('parameters_pages', $pages);
    }
1085052
public function handle(GetGlobalButtonEvent $event)
    {
        if (!$this->scopeDeterminator->currentScopeIsBackend()) {
            return;
        }

        if ('button_new' !== $event->getKey()) {
            return;
        }

        $environment     = $event->getEnvironment();
        $basicDefinition = $environment->getDataDefinition()->getBasicDefinition();
        $mode            = $basicDefinition->getMode();

        if (!$basicDefinition->isCreatable()) {
            $event->setHtml('');
            return;
        }

        if ((BasicDefinitionInterface::MODE_PARENTEDLIST === $mode)
            || (BasicDefinitionInterface::MODE_HIERARCHICAL === $mode)
        ) {
            $filter = new Filter();
            $filter->andModelIsFromProvider($basicDefinition->getDataProvider());
            if ($parentDataProviderName = $basicDefinition->getParentDataProvider()) {
                $filter->andParentIsFromProvider($parentDataProviderName);
            } else {
                $filter->andHasNoParent();
            }

            if ($environment->getClipboard()->isNotEmpty($filter)) {
                $event->setHtml('');
                return;
            }
        }

        $url = UrlBuilder::fromUrl($event->getHref());
        if ($serializedPid = $environment->getInputProvider()->getParameter('pid')) {
            $url->setQueryParameter('pid', ModelId::fromSerialized($serializedPid)->getSerialized());
        }

        $event->setHref($url->getUrl());
    }
698955
public function onDisplayDesktop(DisplayToolEvent $event)
    {
        $content = $this->templating->render(
            'ClarolineCoreBundle:tool:resources.html.twig', [
                'context' => [
                    'type' => Widget::CONTEXT_DESKTOP,
                ],
                'root' => null,
            ]
        );

        $event->setContent($content);
        $event->stopPropagation();
    }
1199069
public function onAdministrationToolOpen(OpenAdministrationToolEvent $event)
    {
        $content = $this->templating->render(
            'ClarolineTagBundle:administration:tags.html.twig', [
                'context' => [
                    'type' => Tool::ADMINISTRATION,
                ],
            ]
        );

        $event->setResponse(new Response($content));
        $event->stopPropagation();
    }
1268101
public function onDisplayWorkspaceHome(DisplayToolEvent $event)
    {
        $params = array(
            '_controller' => 'ClarolineCoreBundle:Workspace:displayWorkspaceHomeTab',
            'workspace' => $event->getWorkspace()->getId(),
            'tabId' => -1
        );
        $subRequest = $this->container->get('request')->duplicate(array(), null, $params);
        $response = $this->httpKernel->handle($subRequest, HttpKernelInterface::SUB_REQUEST);

        $event->setContent($response->getContent());
    }
1078171
public function onOpenDesktopTool(DisplayToolEvent $event)
    {
        $params = array();
        $params['_controller'] = 'ClarolineMessageBundle:Message:listReceived';
        $params['page'] = 1;
        $params['search'] = '';
        $subRequest = $this->request->duplicate(array(), null, $params);
        $response = $this->httpKernel->handle($subRequest, HttpKernelInterface::SUB_REQUEST);
        $event->setContent($response->getContent());
        $event->stopPropagation();
    }
313043
public function onDisplayWorkspace(DisplayToolEvent $event)
    {
        $workspace = $event->getWorkspace();

        $content = $this->templating->render(
            'ClarolineCoreBundle:workspace:analytics.html.twig', [
                'workspace' => $workspace,
            ]
        );

        $event->setContent($content);
        $event->stopPropagation();
    }
514257
public function onDisplay(DisplayToolEvent $event)
    {
        if (!$this->request) {
            throw new NoHttpRequestException();
        }

        $subRequest = $this->request->duplicate(
            array(),
            null,
            array(
                '_controller' => 'ClarolineCoreBundle:Tool\Roles:usersList',
                'workspace' => $event->getWorkspace(),
                'page' => 1,
                'search' => '',
                'max' => 50,
                'order' => 'id'
            )
        );
        $response = $this->httpKernel->handle($subRequest, HttpKernelInterface::SUB_REQUEST);
        $event->setContent($response->getContent());
    }