X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fmodules%2Fcontrib%2Fredirect%2Fsrc%2FEntity%2FRedirect.php;fp=web%2Fmodules%2Fcontrib%2Fredirect%2Fsrc%2FEntity%2FRedirect.php;h=cb5d4c56dd54f1bd12c3af2d4a5260133d590806;hp=ae54ec576b94cc0a4a5bd63387a2af25f8017ab7;hb=059867c3f96750652c80f39e44c442a58c2549ee;hpb=f8fc16ae6b862bef59baaad5d051dd37b7ff11b2 diff --git a/web/modules/contrib/redirect/src/Entity/Redirect.php b/web/modules/contrib/redirect/src/Entity/Redirect.php index ae54ec576..cb5d4c56d 100644 --- a/web/modules/contrib/redirect/src/Entity/Redirect.php +++ b/web/modules/contrib/redirect/src/Entity/Redirect.php @@ -3,7 +3,6 @@ namespace Drupal\redirect\Entity; use Drupal\Component\Utility\Crypt; -use Drupal\Component\Utility\Unicode; use Drupal\Component\Utility\UrlHelper; use Drupal\Core\Entity\ContentEntityBase; use Drupal\Core\Entity\EntityStorageInterface; @@ -25,7 +24,7 @@ use Drupal\link\LinkItemInterface; * "delete" = "Drupal\redirect\Form\RedirectDeleteForm", * "edit" = "Drupal\redirect\Form\RedirectForm" * }, - * "views_data" = "Drupal\views\EntityViewsData", + * "views_data" = "Drupal\redirect\RedirectViewsData", * "storage_schema" = "\Drupal\redirect\RedirectStorageSchema" * }, * base_table = "redirect", @@ -62,7 +61,7 @@ class Redirect extends ContentEntityBase { */ public static function generateHash($source_path, array $source_query, $language) { $hash = array( - 'source' => Unicode::strtolower($source_path), + 'source' => mb_strtolower($source_path), 'language' => $language, ); @@ -86,7 +85,9 @@ class Redirect extends ContentEntityBase { * {@inheritdoc} */ public function preSave(EntityStorageInterface $storage_controller) { - $this->set('hash', Redirect::generateHash($this->redirect_source->path, (array) $this->redirect_source->query, $this->language()->getId())); + // Get the language code directly from the field as language() might not + // be up to date if the language was just changed. + $this->set('hash', Redirect::generateHash($this->redirect_source->path, (array) $this->redirect_source->query, $this->get('language')->value)); } /** @@ -205,7 +206,9 @@ class Redirect extends ContentEntityBase { */ public function setRedirect($url, array $query = array(), array $options = array()) { $uri = $url . ($query ? '?' . UrlHelper::buildQuery($query) : ''); - $this->redirect_redirect->set(0, ['uri' => 'internal:/' . ltrim($uri, '/'), 'options' => $options]); + $external = UrlHelper::isValid($url, TRUE); + $uri = ($external ? $url : 'internal:/' . ltrim($uri, '/')); + $this->redirect_redirect->set(0, ['uri' => $uri, 'options' => $options]); } /**