You are here

protected function LoadMatchingRedirect::getExistingRedirect in Acquia Content Hub 8.2

Looks for an existing redirect based on data from the CDF.

Parameters

array $redirect_source: The redirect source data from the CDF.

string $langcode: The langcode.

Return value

\Drupal\redirect\Entity\Redirect|null The existing Redirect (if any).

1 call to LoadMatchingRedirect::getExistingRedirect()
LoadMatchingRedirect::onLoadLocalEntity in modules/acquia_contenthub_subscriber/src/EventSubscriber/LoadLocalEntity/LoadMatchingRedirect.php
Loads local matching redirects to avoid duplicate redirect errors.

File

modules/acquia_contenthub_subscriber/src/EventSubscriber/LoadLocalEntity/LoadMatchingRedirect.php, line 81

Class

LoadMatchingRedirect
Class LoadMatchingRedirect.

Namespace

Drupal\acquia_contenthub_subscriber\EventSubscriber\LoadLocalEntity

Code

protected function getExistingRedirect(array $redirect_source, string $langcode) : ?Redirect {
  $query = $redirect_source['value'][$langcode]['query'] ?? [];
  $path = $redirect_source['value'][$langcode]['path'];

  /** @var \Drupal\Redirect\RedirectRepository $redirect_repository */
  $redirect_repository = \Drupal::service('redirect.repository');
  $existing_redirect = $redirect_repository
    ->findMatchingRedirect($path, $query, $langcode);
  return $existing_redirect;
}