diff --git a/src/PathautoState.php b/src/PathautoState.php index 6415252..2f66794 100644 --- a/src/PathautoState.php +++ b/src/PathautoState.php @@ -38,7 +38,7 @@ class PathautoState extends TypedData { // If no value has been set or loaded yet, try to load a value if this // entity has already been saved. $this->value = \Drupal::keyValue($this->getCollection()) - ->get($this->parent->getEntity()->id()); + ->get($this->getKey()); // If it was not yet saved or no value was found, then set the flag to // create the alias if there is a matching pattern. if ($this->value === NULL) { @@ -73,17 +73,26 @@ class PathautoState extends TypedData { */ public function persist() { \Drupal::keyValue($this->getCollection())->set( - $this->parent->getEntity() - ->id(), $this->value + $this->getKey(), $this->value ); } /** + * Get the Entity ID and LangCode. + */ + private function getKey() { + $entity_id = $this->parent->getEntity()->id(); + $entity_lang_code = $this->parent->getEntity()->language()->getId(); + + return "{$entity_id}:{$entity_lang_code}"; + } + + /** * Deletes the stored state. */ public function purge() { \Drupal::keyValue($this->getCollection()) - ->delete($this->parent->getEntity()->id()); + ->delete($this->getKey()); } /**