Stop propagation if the document is already loaded in the requested locale.

@param HydrateEvent $event
343524
public function handleStopPropagationAndResetLocale(HydrateEvent $event)
    {
        if (!$event->hasDocument()) {
            return;
        }

        $locale = $event->getLocale();
        $document = $event->getDocument();
        $options = $event->getOptions();
        $originalLocale = $this->documentRegistry->getOriginalLocaleForDocument($document);

        if (
            (!isset($options['rehydrate']) || false === $options['rehydrate']) &&
            (true === $this->documentRegistry->isHydrated($document) && $originalLocale === $locale)
        ) {
            $event->stopPropagation();
        }
    }
1065444
public function handleRemovePage(RemoveEvent $event)
    {
        $document = $event->getDocument();
        if (!$document instanceof ArticlePageDocument) {
            return;
        }

        $document = $document->getParent();
        $this->documents[$document->getUuid()] = [
            'uuid' => $document->getUuid(),
            'locale' => $document->getLocale(),
        ];
    }
415889
public function handleHydrate(AbstractMappingEvent $event)
    {
        $document = $event->getDocument();
        if (!$document instanceof RoutablePageBehavior) {
            return;
        }

        $locale = $document->getLocale();
        if (LocalizationState::SHADOW === $this->documentInspector->getLocalizationState($document)) {
            $locale = $document->getOriginalLocale();
        }

        $propertyName = $this->getRoutePathPropertyName($document->getStructureType(), $locale);
        $routePath = $event->getNode()->getPropertyValueWithDefault($propertyName, null);
        $document->setRoutePath($routePath);

        $route = $this->routeRepository->findByEntity($document->getClass(), $document->getUuid(), $locale);
        if ($route) {
            $document->setRoute($route);
        }
    }
723270
public function clearEventHandlers($event = null)
    {
        if (!empty($event)) {
            $this->events[$event] = [];
        } else {
            $this->events = [];
        }
    }
814049
public function handleChildrenPersist(PersistEvent $event)
    {
        $document = $event->getDocument();
        if (!$document instanceof ArticleDocument) {
            return;
        }

        foreach ($document->getChildren() as $childDocument) {
            if (!$childDocument instanceof ArticlePageDocument) {
                continue;
            }

            $localizationState = $this->documentInspector->getLocalizationState($childDocument);

            if (LocalizationState::GHOST === $localizationState) {
                continue;
            }

            $changed = false;

            if ($document->getStructureType() !== $childDocument->getStructureType()) {
                $childDocument->setStructureType($document->getStructureType());
                $changed = true;
            }

            if ($document->getShadowLocale() !== $childDocument->getShadowLocale()) {
                $childDocument->setShadowLocale($document->getShadowLocale());
                $changed = true;
            }

            if ($document->isShadowLocaleEnabled() !== $childDocument->isShadowLocaleEnabled()) {
                $childDocument->setShadowLocaleEnabled($document->isShadowLocaleEnabled());
                $changed = true;
            }

            if ($changed) {
                $this->documentManager->persist(
                    $childDocument,
                    $childDocument->getLocale(),
                    [
                        'clear_missing_content' => false,
                        'auto_name' => false,
                        'auto_rename' => false,
                    ]
                );
            }
        }
    }
1217592
public function handleFlush(FlushEvent $event)
    {
        if (count($this->documents) < 1) {
            return;
        }

        foreach ($this->documents as $documentData) {
            $document = $this->documentManager->find($documentData['uuid'], $documentData['locale']);
            $this->documentManager->refresh($document);

            $this->indexer->index($document);
        }
        $this->indexer->flush();
        $this->documents = [];
    }
234920
public function onDelete(DeleteResourceEvent $event)
    {
        /** @var File $file */
        $file = $event->getResource();

        $pathName = $this->filesDir.DIRECTORY_SEPARATOR.$file->getHashName();

        if (file_exists($pathName)) {
            $event->setFiles([$pathName]);
        }

        $event->stopPropagation();
    }
355636
public function handleRemove(RemoveEvent $event)
    {
        $document = $event->getDocument();
        $node = $this->documentRegistry->getNodeForDocument($document);

        $node->remove();
    }
1047499
public function onKernelRequest(GetResponseEvent $event): void
    {
        $request = $event->getRequest();

        if (HttpKernelInterface::MASTER_REQUEST !== $event->getRequestType() || !$this->isAdminSiteAccess($request)) {
            return;
        }

        $additionalTranslations = $this->configResolver->getParameter('user_preferences.additional_translations');
        $preferableLocales = $this->userLanguagePreferenceProvider->getPreferredLocales($request);
        $locale = null;

        foreach ($preferableLocales as $preferableLocale) {
            if (\in_array($preferableLocale, $this->availableTranslations, true)
                || \in_array($preferableLocale, $additionalTranslations, true)
            ) {
                $locale = $preferableLocale;
                break;
            }
        }
        $locale = $locale ?? reset($preferableLocales);
        $request->setLocale($locale);
        $request->attributes->set('_locale', $locale);
        // Set of the current locale on the translator service is needed because RequestLocaleListener has lower
        // priority than LocaleListener and messages are not translated on login, forgot and reset password pages.
        $this->translator->setLocale($locale);
    }
842228
public function onPostHydrate(HydrationEvent $event)
    {
        $entity = $event->getSubject();
        if (!$entity instanceof Entity\Users) {
            return;
        }

        // Ensure Permissions::ROLE_EVERYONE always exists
        $roles = $entity->getRoles();
        if (!in_array(Permissions::ROLE_EVERYONE, $roles)) {
            $roles[] = Permissions::ROLE_EVERYONE;
            $entity->setRoles($roles);
        }
    }
215891
public function stopListening($event, $callback)
    {
        if (!isset($this->events[$event])) {
            return true;
        }

        $key = array_search($callback, $this->events[$event]);
        if ($key !== false) {
            unset($this->events[$event][$key]);
        }

        return true;
    }
227847
protected function doSendEvent(Event $event): void
    {
        $envelope = new TransportEnvelope($event, 'json');
        $this->client->putRecord([
            'StreamName'   => $this->router->forEvent($event),
            'PartitionKey' => $this->router->partitionForEvent($event),
            'Data'         => $envelope->toString(),
        ]);
    }
1106737
public static function removeAllListeners(string $event) : void
    {
        if (Event::hasListeners($event)) {
            unset(Event::$listeners[$event]);
        }
    }
857105
public function beforeSend($event = null)
    {
        if (isset($this->stream)) {
            return;
        }
        if (isset($this->controller) && $this->task) {
            if ($this->isInstructable) {
                $this->format = static::FORMAT_JSON;
                $this->data = $this->generateInstructions();
            } else {
                $this->handleFlashStatus();
                if ($this->redirect) {
                    $this->redirect($this->redirect);
                } elseif ($this->refresh) {
                    $this->refresh();
                } else {
                    if (is_null($this->content)) {
                        $this->content = $this->renderContent(true);
                    }
                }
            }
        }
    }
1070387
protected function hydrateEvent(array $i18nRow, CustomerTitleEvent $event)
    {
        $event
            ->setShort($i18nRow["short"])
            ->setLong($i18nRow["long"])
            ->setLocale($i18nRow["locale"])
        ;
    }
692016
function( event ) {
            event = $.getEvent( event );

            if ( event.stopPropagation ) {
                // W3C for stopping propagation
                $.stopEvent = function( event ){
                    event.stopPropagation();
                };
            } else {
                // IE for stopping propagation
                $.stopEvent = function( event ){
                    event = $.getEvent( event );
                    event.cancelBubble = true;
                };

            }

            $.stopEvent( event );
        }
917320
public function forget(Event $event)
    {
        $this->cache->store($this->store)->forget($event->mutexName());
    }