Handle a load language file event.

@param LoadLanguageFileEvent $event The event.

@return void
432244
public function handleLoadLanguageFile(LoadLanguageFileEvent $event)
    {
        /** @var System $systemAdapter */
        $systemAdapter = $this->framework->getAdapter(System::class);

        $systemAdapter->loadLanguageFile($event->getFileName(), $event->getLanguage(), $event->isCacheIgnored());
    }
273201
private function load()
	{
		if ($this->isLoaded())
		{
			return;
		}

		$path = sprintf('%s/../../lang/%s.php', __DIR__, $this->locale);

		if (file_exists($path))
		{
			$this->loaded[$this->locale] = require $path;
		}
	}
126143
public function onProcessFile(FileEvent $event)
    {
        if ($this->isAppropriate($event) === false) {
            return;
        }
        $this->makeTemporary($event);

        $this->processFile($event);
    }
165563
public function loadLocaleFile($file, $domain) {
		$filename = $this->findLocaleFile($file);

		if ($filename !== null) {
			$locale = $this->getLocaleFromFilename($filename);
			$translator = $this->service->getTranslator();
			$translator->addResource('json', $filename, $locale, $domain);
		}
	}
600297
public function handleDefaultLocale(HydrateEvent $event)
    {
        // set the default locale
        if (null === $event->getLocale()) {
            $event->setLocale($this->documentRegistry->getDefaultLocale());
        }
    }
930675
public function handle(EventMessage $event)
    {
        if ($event instanceof \PAMI\Message\Event\AsyncAGIEvent) {
            if ($event->getCommandId() == $this->lastCommandId) {
                $this->lastAgiResult = trim($event->getResult());
            }
        }
    }
250752
public function onKernelRequest(GetResponseEvent $event)
    {
        $request = $event->getRequest();

        if (!$locale = $this->determineLocale($event)) {
            return;
        }

        $this->chooser->setLocale($locale);

        if (self::FALLBACK_HARDCODED === $this->fallback) {
            return;
        }

        // expand language list to include base locales
        // copy-pasted from Request::getPreferredLanguage
        $preferredLanguages = $request->getLanguages();
        $extendedPreferredLanguages = [];
        foreach ($preferredLanguages as $language) {
            $extendedPreferredLanguages[] = $language;
            if (false !== $position = strpos($language, '_')) {
                $superLanguage = substr($language, 0, $position);
                if (!in_array($superLanguage, $preferredLanguages)) {
                    $extendedPreferredLanguages[] = $superLanguage;
                }
            }
        }
        $order = array_intersect($this->allowedLocales, $extendedPreferredLanguages);
        $this->chooser->setFallbackLocales($locale, $order, self::FALLBACK_REPLACE === $this->fallback);
    }
241630
protected function handleError(Event $event): void
    {
        $logErrors = $this->configuration
            ->get('log_errors')
        ;
        $emailErrors = $this->configuration
            ->get('email_errors')
        ;

        if ($logErrors) {
            $this->logger->error($this->formatEventError($event));
        } else {
            $output = $event->wholeOutput();

            $this->output
                ->write("<error>{$output}</error>");
        }

        // Send error as email as configured
        if ($emailErrors) {
            $this->mailer->send(
                'Crunz: reporting error for event:' . (($event->description) ? $event->description : $event->getId()),
                $this->formatEventError($event)
            );
        }
    }
385260
public function onLoad(LoadResourceEvent $event)
    {
        /** @var Blog $blog */
        $blog = $event->getResource();
        $this->checkPermission('OPEN', $blog->getResourceNode(), [], true);

        $postManager = $this->container->get('icap.blog.manager.post');
        $blogManager = $this->container->get('icap_blog.manager.blog');

        $parameters['limit'] = -1;

        $posts = $postManager->getPosts(
            $blog->getId(),
            $parameters,
            $this->checkPermission('ADMINISTRATE', $blog->getResourceNode())
            || $this->checkPermission('EDIT', $blog->getResourceNode())
            || $this->checkPermission('MODERATE', $blog->getResourceNode())
                ? PostManager::GET_ALL_POSTS
                : PostManager::GET_PUBLISHED_POSTS,
            !$blog->getOptions()->getDisplayFullPosts());

        $postsData = [];
        if (!empty($posts)) {
            $postsData = $posts['data'];
        }

        $event->setData([
          'authors' => $postManager->getAuthors($blog),
          'archives' => $postManager->getArchives($blog),
          'tags' => $blogManager->getTags($blog, $postsData),
          'blog' => $this->container->get('claroline.api.serializer')->serialize($blog),
          'pdfEnabled' => $this->container->get('claroline.config.platform_config_handler')->getParameter('is_pdf_export_active'),
        ]);

        $event->stopPropagation();
    }
1017453
public function onAfterInitialise(Event $event): void
    {
        /** @var WebApplication $app */
        $app = $event['app'];

        // Remove index.php
        if ($app->uri->script === 'index.php') {
            $app->uri->script = null;
        }
    }
1345179
public function onCommand(CommandEvent $event)
    {
        switch ($event->getCommandName()) {
            case 'dump-autoload':
                $_this = new DumpAutoloadEventHandler(
                    $this->__installer->getComposer()->getPackage(),
                    $this->__installer->getComposer()
                );
                break;
            default: break;
        }
    }
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();
    }
917062
public function onBeforeAddLanguageCommit(BeforeAddLanguageCommitEvent $event)
    {
        if ($event->isAborted()) {
            return;
        }

        $this->languageManager = $event->getContentManager();
        $languageRepository = $this->languageManager->getLanguageRepository();

        $this->mainLanguage = $languageRepository->mainLanguage();
        if (null === $this->mainLanguage) {
            $event->abort();

            return;
        }

        $this->sourceObjects = $this->setUpSourceObjects();
        if (count($this->sourceObjects) > 0) {
            try {
                $result = true;
                $languageRepository->startTransaction();
                foreach ($this->sourceObjects as $sourceObject) {
                    $values = $sourceObject->toArray();
                    $result = $this->copy($values);
                    if (!$result) {
                        break;
                    }
                }

                if (false !== $result) {
                    $languageRepository->commit();
                } else {
                    $languageRepository->rollBack();

                    $event->abort();
                }
            } catch (\Exception $e) {
                $event->abort();
                if (isset($languageRepository) && $languageRepository !== null) {
                    $languageRepository->rollBack();
                }

                throw $e;
            }
        }
    }
1186656
public function onPreAutoloadDump(Event $event)
    {
        $basePath = $this->getBasePath($event);
        $lockPath = "{$basePath}/pre.lock";

        $shouldOptimize = $this->shouldOptimize($event);

        if ($shouldOptimize) {
            file_put_contents($lockPath, time());

            if (!file_exists("{$basePath}/vendor/autoload.php")) {
                return;
            }

            require_once "{$basePath}/vendor/autoload.php";

            $directory = new RecursiveDirectoryIterator($basePath);

            $files = new RecursiveIteratorIterator(
                $directory, RecursiveIteratorIterator::SELF_FIRST
            );

            foreach ($files as $file) {
                if (stripos($file, "{$basePath}/vendor") === 0) {
                    continue;
                }

                if ($file->getExtension() !== "pre") {
                    continue;
                }

                $pre = $file->getPathname();
                $php = preg_replace("/pre$/", "php", $pre);

                compile(
                    $pre, $php, $format = true, $comment = false
                );
            }
        } else {
            if (file_exists($lockPath)) {
                unlink($basePath . "/pre.lock");
            }
        }
    }
127278
public function beforeDispatch(Event $event)
    {
        /* @var \Cake\Http\ServerRequest $request */
        $request = $event->getData('request');
        $locale = Locale::acceptFromHttp($request->getHeaderLine('Accept-Language'));

        if (!$locale || (!empty($this->_locales) && !in_array($locale, $this->_locales))) {
            return;
        }

        I18n::setLocale($locale);
    }
283230
protected function addLoaderFile(string $file, string $locale = null): void
	{
		if ($this->loader === null) {
			$builder = $this->getContainerBuilder();

			$loader = $builder->getByType(LoaderFactory::class);
			$this->loader = $builder->getDefinition($loader);
		}
		$this->loader->addSetup('addFile', [$file, $locale]);
	}
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();
    }