class NodeTranslationExceptionSubscriber implements EventSubscriberInterface (View source)

Redirect node translations that have been consolidated by migration.

If we migrated node translations from Drupal 6 or 7, these nodes are now combined with their source language node. Since there still might be references to the URLs of these now consolidated nodes, this service catches the 404s and try to redirect them to the right node in the right language.

The mapping of the old nids to the new ones is made by the NodeTranslationMigrateSubscriber class during the migration and is stored in the "node_translation_redirect" key/value collection.

Properties

protected KeyValueFactoryInterface $keyValue

The key value factory.

protected LanguageManagerInterface $languageManager

The language manager.

protected UrlGeneratorInterface $urlGenerator

The URL generator.

protected StateInterface $state

The state service.

Methods

__construct(KeyValueFactoryInterface $key_value, LanguageManagerInterface $language_manager, UrlGeneratorInterface $url_generator, StateInterface $state)

Constructs the NodeTranslationExceptionSubscriber.

onException(ExceptionEvent $event)

Redirects not found node translations using the key value collection.

static array
getSubscribedEvents()

{@inheritdoc}

Details

__construct(KeyValueFactoryInterface $key_value, LanguageManagerInterface $language_manager, UrlGeneratorInterface $url_generator, StateInterface $state)

Constructs the NodeTranslationExceptionSubscriber.

Parameters

KeyValueFactoryInterface $key_value

The key value factory.

LanguageManagerInterface $language_manager

The language manager.

UrlGeneratorInterface $url_generator

The URL generator.

StateInterface $state

The state service.

onException(ExceptionEvent $event)

Redirects not found node translations using the key value collection.

Parameters

ExceptionEvent $event

The exception event.

static array getSubscribedEvents()

{@inheritdoc}

Return Value

array