public function onException(ExceptionEvent
$event) { $exception =
$event->
getThrowable();
// If this is not a 404, we don't need to check for a redirection.
if (!
($exception instanceof NotFoundHttpException
)) { return;
} $previous_exception =
$exception->
getPrevious();
if ($previous_exception instanceof ParamNotConvertedException
) { $route_name =
$previous_exception->
getRouteName();
$parameters =
$previous_exception->
getRawParameters();
if ($route_name === 'entity.node.canonical' &&
isset($parameters['node'
])) { // If the node_translation_redirect state is not set, we don't need to check
// for a redirection.
if (!
$this->state->
get('node_translation_redirect'
)) { return;
} $old_nid =
$parameters['node'
];
$collection =
$this->keyValue->
get('node_translation_redirect'
);
if ($old_nid &&
$value =
$collection->
get($old_nid)) { [$nid,
$langcode] =
$value;