@DI\Observe("claroline_retrieve_user_workspaces_by_tag")

@param GenericDatasEvent $event
357731
public function onRetrieveUserWorkspacesByTag(GenericDatasEvent $event)
    {
        $workspaces = array();
        $datas = $event->getDatas();

        if (is_array($datas) && isset($datas['user']) && isset($datas['tag'])) {
            $user = $datas['user'];
            $tag = $datas['tag'];
            $orderedBy = isset($datas['ordered_by']) ? $datas['ordered_by'] : 'id';
            $order = isset($datas['order']) ? $datas['order'] : 'ASC';
            $workspaces = $this->tagManager->getTaggedWorkspacesByRoles(
                $user,
                $tag,
                $orderedBy,
                $order
            );
        }
        $event->setResponse($workspaces);
    }
396808
public function onPreRequest(ehough_tickertape_GenericEvent $event)
    {
        $request = $event->getSubject();

        $this->_isDebugEnabled = $this->_logger->isHandling(ehough_epilog_Logger::DEBUG);

        $this->_setDefaultHeadersBasic($request);
        $this->_setDefaultHeadersCompression($request);
        $this->_setDefaultHeadersContent($request);
    }
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());
    }
183132
public function onWorkspaceActionMenuRender(WorkspaceAdditionalActionEvent $event)
    {
        $workspace = $event->getWorkspace();
        $url = $this->router->generate(
            'claro_tag_workspace_tag_form',
            array('workspace' => $workspace->getId())
        );

        $menu = $event->getMenu();
        $menu->addChild(
            $this->translator->trans('tag_action', array(), 'tag'),
            array('uri' => $url)
        )->setExtra('icon', 'fa fa-tags')
        ->setExtra('display', 'modal_form');

        return $menu;
    }
667012
public function onPrepareWorkspaceUploadMaintenancePage(WorkspaceEvent $event, $eventName, EventDispatcherInterface $eventDispatcher)
    {
        $host = $event->getWorkspace()->getHost();
        $connection = $this->ensureConnection($host);

        $directory = sprintf('%s/maintenance/%s', $host->getPath(), $this->documentRoot);
        $context = array('directory' => $directory, 'event.task.action' => TaskInterface::ACTION_IN_PROGRESS);

        $eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::NOTICE, 'Creating directory "{directory}".', $eventName, $this, $context));
        if ($connection->isDirectory($directory) === false) {
            if ($connection->createDirectory($directory, 0770, true)) {
                $context['event.task.action'] = TaskInterface::ACTION_COMPLETED;
                $context['output.resetLine'] = true;

                $eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::NOTICE, 'Created directory "{directory}".', $eventName, $this, $context));
            } else {
                $context['event.task.action'] = TaskInterface::ACTION_FAILED;
                $context['output.resetLine'] = true;

                $eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::WARNING, 'Failed creating directory "{directory}".', $eventName, $this, $context));
            }
        } else {
            $context['event.task.action'] = TaskInterface::ACTION_COMPLETED;
            $context['output.resetLine'] = true;

            $eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::NOTICE, 'Directory "{directory}" exists.', $eventName, $this, $context));
        }

        if ($connection->isDirectory($directory)) {
            $files = array_diff(scandir($this->localMaintenanceDirectory), array('.', '..'));
            foreach ($files as $file) {
                $localFile = $this->localMaintenanceDirectory.'/'.$file;
                if (is_file($localFile)) {
                    $context = array('file' => $localFile, 'event.task.action' => TaskInterface::ACTION_COMPLETED);

                    $uploaded = $connection->putFile($localFile, $directory.'/'.$file);
                    if ($uploaded === true) {
                        $eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::INFO, 'Uploaded file "{file}".', $eventName, $this, $context));
                    }
                }
            }
        }
    }
207619
public function onPostListQueryBuilder(GenericEvent $event)
    {
        $queryBuilder = $event->getArgument('query_builder');

        // Request filters
        if ($event->hasArgument('request')) {
            $this->applyRequestFilters($queryBuilder, $event->getArgument('request')->get('filters', []));
        }

        // List form filters
        if ($event->hasArgument('entity')) {
            $entityConfig = $event->getArgument('entity');
            if (isset($entityConfig['list']['form_filters'])) {
                $listFormFiltersForm = $this->listFormFiltersHelper->getListFormFilters($entityConfig['list']['form_filters']);
                if ($listFormFiltersForm->isSubmitted() && $listFormFiltersForm->isValid()) {
                    $this->applyFormFilters($queryBuilder, $listFormFiltersForm->getData());
                }
            }
        }
    }
365980
public function onSniff(GenericEvent $event)
    {
        $context = $event->getArguments();

        $this->logger->debug('Visiting SNIFF, process {method} {sniff}', $context);
    }
1338574
public function onReflectSuccess(GenericEvent $event)
    {
        $context = $event->getArguments();
        $this->logger->info('Analyze file "{file}" successful.', $context);
    }
1148613
public function notify( ServesEventData $event )
	{
		$namespaceComponents = explode( "\\", get_class( $event ) );
		$methodName          = sprintf( 'when%s', preg_replace( "#Event$#", '', end( $namespaceComponents ) ) );

		if ( is_callable( [ $this, $methodName ] ) )
		{
			$this->{$methodName}( $event );
		}
		else
		{
			throw new EventListenerMethodNotCallable( $methodName );
		}
	}
718898
protected void onDataSetStaleEvent(@Observes DataSetStaleEvent event) {
        DataSetDef def = event.getDataSetDef();
        if (DataSetProviderType.BEAN.equals(def.getProvider())) {
            staticDataSetProvider.removeDataSet(def.getUUID());
        }
    }
484111
public function onWorkspaceToolOpen(DisplayToolEvent $event)
    {
        $workspace = $event->getWorkspace();
        $teamParams = $this->teamManager->getWorkspaceTeamParameters($workspace);
        $canEdit = $this->authorization->isGranted(['claroline_team_tool', 'edit'], $workspace);
        $resouceTypes = $this->resourceTypeRepo->findBy(['isEnabled' => true]);
        $user = $this->tokenStorage->getToken()->getUser();
        $myTeams = 'anon.' !== $user ?
            $this->teamManager->getTeamsByUserAndWorkspace($user, $workspace) :
            [];
        $content = $this->templating->render(
            'ClarolineTeamBundle:team:tool.html.twig', [
                'workspace' => $workspace,
                'teamParams' => $teamParams,
                'canEdit' => $canEdit,
                'myTeams' => array_map(function (Team $team) {
                    return $team->getUuid();
                }, $myTeams),
                'resourceTypes' => array_map(function (ResourceType $resourceType) {
                    return $resourceType->getName();
                }, $resouceTypes),
            ]
        );
        $event->setContent($content);
        $event->stopPropagation();
    }
772312
public function onDelete(GenericDataEvent $event)
    {
        /** @var UserEntity[] $users */
        $users = $event->getData();

        $ids = [];
        foreach ($users as $user) {
            $ids[] = $user->getId();
        }

        $this->manager->removeTaggedObjectsByClassAndIds(UserEntity::class, $ids);
    }
200243
public function onDisplayWorkspace(DisplayToolEvent $event)
    {
        $levelMax = 1;
        $workspace = $event->getWorkspace();
        $authenticatedUser = $this->tokenStorage->getToken()->getUser();
        $user = 'anon.' !== $authenticatedUser ? $authenticatedUser : null;
        $items = $this->progressionManager->fetchItems($workspace, $user, $levelMax);

        $content = $this->templating->render(
            'ClarolineCoreBundle:tool:progression.html.twig', [
                'workspace' => $workspace,
                'context' => [
                    'type' => 'workspace',
                    'data' => $this->serializer->serialize($workspace),
                ],
                'items' => $items,
                'levelMax' => null,    // how deep to process children recursively
            ]
        );

        $event->setContent($content);
        $event->stopPropagation();
    }
594283
public function onExecuteMessageTask(GenericDataEvent $event)
    {
        /** @var ScheduledTask $task */
        $task = $event->getData();
        $data = $task->getData();
        $users = $task->getUsers();
        $object = isset($data['object']) ? $data['object'] : null;
        $content = isset($data['content']) ? $data['content'] : null;

        if (!empty($users) && !empty($object) && !empty($content)) {
            $message = $this->messageManager->create($content, $object, $users);
            $this->messageManager->send($message);
            $this->taskManager->markAsExecuted($task);
        }

        $event->stopPropagation();
    }
881458
public function onDataReady(DataEvent $event)
    {
        $data  = array();
       
        foreach ($event->getData() as $key => $row){
            foreach ($row as $field => $value){
                
                if($value instanceof \DateTime){
                    
                    $formatter = \IntlDateFormatter::create(
                        $this->locale,
                        static::$formats[$this->dateFormat],
                        static::$formats[$this->timeFormat],
                        $this->timezone,
                        IntlDateFormatter::GREGORIAN,
                        $this->format
                    );

                    if(!$formatter){
                        $formatter = IntlDateFormatter::create(
                            'en',
                            static::$formats[$this->dateFormat],
                            static::$formats[$this->timeFormat],
                            $this->timezone,
                            \IntlDateFormatter::GREGORIAN,
                            $this->format
                        );
                    }

                    $value =  $formatter->format($value->getTimestamp());

                }
                
                $data[$key][$field] = $value;
            }
        }
        
        $event->setData($data);
    }
352185
public function onPrepareWorkspaceConstructWorkspaceInstance(WorkspaceEvent $event, $eventName, EventDispatcherInterface $eventDispatcher)
    {
        $eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::NOTICE, 'Creating Workspace.', $eventName, $this, array('event.task.action' => TaskInterface::ACTION_IN_PROGRESS)));

        $workspace = new Workspace($event->getHost());
        $workspace->setReleasesDirectory($this->releasesDirectory);
        $workspace->setDataDirectory($this->dataDirectory);
        $workspace->setCacheDirectory($this->cacheDirectory);
        $workspace->setOtherDirectories($this->otherDirectories);

        $event->setWorkspace($workspace);

        $eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::NOTICE, 'Created Workspace.', $eventName, $this, array('event.task.action' => TaskInterface::ACTION_COMPLETED, 'output.resetLine' => true)));
    }
32762
public function getData(GetDataEvent $event)
    {
        $options = $event->getOptions() ? $event->getOptions() : [];
        $options['hiddenFilters']['moderation'] = false;

        if (DataSource::CONTEXT_WORKSPACE === $event->getContext()) {
            $options['hiddenFilters']['workspace'] = $event->getWorkspace()->getUuid();
        } elseif (DataSource::CONTEXT_HOME === $event->getContext()) {
            $options['hiddenFilters']['anonymous'] = true;
        }
        $event->setData(
            $this->finder->search(Message::class, $options)
        );

        $event->stopPropagation();
    }