@DI\Observe("resource.claroline_scorm.load")

@param LoadResourceEvent $event
548523
public function onLoad(LoadResourceEvent $event)
    {
        $scorm = $event->getResource();
        $user = $this->tokenStorage->getToken()->getUser();

        if ('anon.' === $user) {
            $user = null;
        }
        $event->setData([
            'scorm' => $this->serializer->serialize($scorm),
            'userEvaluation' => is_null($user) ?
                null :
                $this->serializer->serialize(
                    $this->resourceEvalManager->getResourceUserEvaluation($scorm->getResourceNode(), $user)
                ),
            'trackings' => $this->scormManager->generateScosTrackings($scorm->getRootScos(), $user),
        ]);
        $event->stopPropagation();
    }
1367638
public function onApiCreate(CreateResourceEvent $event)
    {
        $request = $this->container->get('request');
        $form = new FileType(true);
        $form->enableApi();
        $form = $this->container->get('form.factory')->create($form, new File());
        $form->submit($this->container->get('request'));


        if ($form->isValid()) {
            $this->handleFileCreation($form, $event);
        }

        $event->setErrorFormContent($form);
        $event->stopPropagation();
    }
99435
public function loadEntitiesAtLoad(LifecycleEventArgs $event)
    {
        if ($this->entityValue && $this->entityValue['entityClass']) {
            $em = $event->getEntityManager();
            if (is_array($this->entityValue) && is_array($this->entityValue['entityId'])) {
                // multiple
                $entityData = $em->getRepository($this->entityValue['entityClass'])->findById($this->entityValue['entityId']); // in this case, $this->entityValue['entityId'] contains an array of entity IDs
            } else {
                // single
                $entityData = $em->getRepository($this->entityValue['entityClass'])->findOneById($this->entityValue['entityId']);
            }

            $this->entityData = $entityData;
        } else {
            $this->entityData = null;
        }
    }
1234350
public function onOpen(OpenResourceEvent $event)
    {
        $text = $event->getResource();
        $collection = new ResourceCollection(array($text->getResourceNode()));
        $isGranted = $this->container->get('security.authorization_checker')->isGranted('EDIT', $collection);
        $revisionRepo = $this->container->get('doctrine.orm.entity_manager')
            ->getRepository('ClarolineCoreBundle:Resource\Revision');
        $content = $this->container->get('templating')->render(
            'ClarolineCoreBundle:Text:index.html.twig',
            array(
                'text' => $revisionRepo->getLastRevision($text)->getContent(),
                '_resource' => $text,
                'isEditGranted' => $isGranted
            )
        );
        $response = new Response($content);
        $event->setResponse($response);
        $event->stopPropagation();
    }
317151
public function load(LoadResourceEvent $event)
    {
        $resourceNode = $event->getResourceNode();

        /** @var Wiki $wiki */
        $wiki = $event->getResource();
        $sectionTree = $this->sectionManager->getSerializedSectionTree(
            $wiki,
            $this->tokenStorage->getToken()->getUser() instanceof User ? $this->tokenStorage->getToken()->getUser() : null,
            $this->checkPermission('EDIT', $resourceNode)
        );

        $event->setData([
            'wiki' => $this->serializer->serialize($wiki),
            'sections' => $sectionTree,
        ]);

        $event->stopPropagation();
    }
1176763
public function open(OpenResourceEvent $event)
    {
        $resource = $event->getResource();
        $workspace = $resource->getResourceNode()->getWorkspace();

        $options = [];
        if (!$this->checkPermission('EDIT', $resource->getResourceNode())) {
            // filter returned posts
            $options[] = AnnouncementAggregateSerializer::VISIBLE_POSTS_ONLY;
        }

        $content = $this->templating->render(
            'ClarolineAnnouncementBundle:announcement:open.html.twig', [
                '_resource' => $resource,
                'announcement' => $this->serializer->serialize($resource, $options),
                'roles' => array_map(function (Role $role) {
                    return $this->serializer->serialize($role, [Options::SERIALIZE_MINIMAL]);
                }, $workspace->getRoles()->toArray()),
            ]
        );

        $event->setResponse(new Response($content));
        $event->stopPropagation();
    }
1063940
public function onDownload(DownloadResourceEvent $event)
    {
        $ds = DIRECTORY_SEPARATOR;
        $scorm = $event->getResource();
        $workspace = $scorm->getResourceNode()->getWorkspace();
        $event->setItem($this->filesDir.$ds.'scorm'.$ds.$workspace->getUuid().$ds.$scorm->getHashName());
        $event->setExtension('zip');
        $event->stopPropagation();
    }
583685
public function onDelete(DeleteResourceEvent $event)
    {
        /** @var Exercise $exercise */
        $exercise = $event->getResource();

        $deletable = $this->exerciseManager->isDeletable($exercise);
        if (!$deletable) {
            // If papers, the Exercise is not completely removed
            $event->enableSoftDelete();
        }

        $event->stopPropagation();
    }
748897
public function onOpen(OpenResourceEvent $event)
    {
        /** @var Lesson $lesson */
        $lesson = $event->getResource();

        $content = $this->templating->render(
            'IcapLessonBundle:lesson:open.html.twig', [
                '_resource' => $lesson,
                'chapter' => $this->chapterRepository->getFirstChapter($lesson),
                'tree' => $this->chapterManager->serializeChapterTree($lesson),
                'root' => $lesson->getRoot(),
            ]
        );

        $event->setResponse(new Response($content));
        $event->stopPropagation();
    }
612844
public function searchResultSet(DataLoadEvent $event)
    {
        if (!in_array(whatwedoSearchBundle::class, $this->container->getParameter('kernel.bundles'))) {
            return;
        }

        $table = $event->getTable();

        if (!$table instanceof DoctrineTable) {
            return;
        }

        // Exec only if query is set
        if ($table->hasExtension(SearchExtension::class)) {
            $query = $table->getSearchExtension()->getSearchQuery();
            if (strlen(trim($query)) == 0) {
                return;
            }
        } else {
            return;
        }

        $model = $table->getQueryBuilder()->getRootEntities()[0];
        $ids = $this->em->getRepository(Index::class)->search($query, $model);

        $table->getQueryBuilder()->andWhere(sprintf(
            '%s.id IN (:q_ids)',
            $table->getQueryBuilder()->getRootAliases()[0]
        ))->setParameter('q_ids', $ids);
    }
984074
public function onCreate(CreateResourceEvent $event)
    {
        $form = $this->formFactory->create(new ActivityType(), new Activity());
        $form->handleRequest($this->request);

        if ($form->isValid()) {
            $published = $form->get('published')->getData();
            $event->setPublished($published);
            $activity = $form->getData();
            $activity->setName($activity->getTitle());
            $activityParameters = new ActivityParameters();
            $activityParameters->setActivity($activity);
            $activity->setParameters($activityParameters);
            $event->setResources(array($activity));
            $event->stopPropagation();

            return;
        }

        $content = $this->templating->render(
            'ClarolineCoreBundle:Resource:createForm.html.twig',
            array(
                'form' => $form->createView(),
                'resourceType' => 'activity'
            )
        );

        $event->setErrorFormContent($content);
        $event->stopPropagation();
    }
526440
function _onLoadEventFired(event, res) {
        // res = {timestamp}
        Inspector.DOM.getDocument(function onGetDocument(res) {
            exports.trigger("getDocument", res);
            // res = {root}
            _idToNode = {};
            _pendingRequests = 0;
            exports.root = new DOMNode(exports, res.root);
        });
    }
529355
public function setCacheForEntity(EntityLoadEvent $event)
    {
        $entity = $event->getEntity();

        if (!$entity->isLoaded()) {
            $this->cache->set($entity);
            $this->dispatcher->dispatch('cache.set', new CacheEvent($entity));
        }
    }
814293
private function initLoader($item, $key, ...$initLoaderArgs): void
    {
        $this->eventDispatcher->dispatch(new ItemEvent(EtlEvents::LOADER_INIT, $item, $key, $this));

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

        ($this->init)(...$initLoaderArgs);
    }
437370
public function onOpen(LoadResourceEvent $event)
    {
        $forum = $event->getResource();
        $user = $this->tokenStorage->getToken()->getUser();
        $isValidatedUser = false;

        if ('anon.' !== $user) {
            $validationUser = $this->manager->getValidationUser($user, $forum);
            $isValidatedUser = $validationUser->getAccess();
        }

        $event->setData([
            'forum' => $this->serializer->serialize($forum),
            'isValidatedUser' => $isValidatedUser,
        ]);

        $event->stopPropagation();
    }
52200
public function load(LoadResourceEvent $event)
    {
        /** @var Shortcut $shortcut */
        $shortcut = $event->getResource();

        $this->resourceLifecycle->load($shortcut->getTarget());
    }
695900
public function loadResource($resourceName)
		{
			$resourceLocation = dirname(__FILE__).DIRECTORY_SEPARATOR."..".DIRECTORY_SEPARATOR."res".DIRECTORY_SEPARATOR.$resourceName;
			$this->resourceContent = $this->readResourceToArray($resourceLocation);
		}