diff -u b/core/lib/Drupal/Core/Entity/ContentEntityBase.php b/core/lib/Drupal/Core/Entity/ContentEntityBase.php --- b/core/lib/Drupal/Core/Entity/ContentEntityBase.php +++ b/core/lib/Drupal/Core/Entity/ContentEntityBase.php @@ -19,6 +19,21 @@ abstract class ContentEntityBase extends Entity implements \IteratorAggregate, ContentEntityInterface { /** + * Status code identifying a removed translation. + */ + const TRANSLATION_REMOVED = 0; + + /** + * Status code identifying an existing translation. + */ + const TRANSLATION_EXISTING = 1; + + /** + * Status code identifying a newly created translation. + */ + const TRANSLATION_CREATED = 2; + + /** * The plain data values of the contained fields. * * This always holds the original, unchanged values of the entity. The values reverted: --- b/core/lib/Drupal/Core/TypedData/TranslatableInterface.php +++ a/core/lib/Drupal/Core/TypedData/TranslatableInterface.php @@ -8,21 +8,6 @@ interface TranslatableInterface { /** - * Status code identifying a removed translation. - */ - const TRANSLATION_REMOVED = 0; - - /** - * Status code identifying an existing translation. - */ - const TRANSLATION_EXISTING = 1; - - /** - * Status code identifying a newly created translation. - */ - const TRANSLATION_CREATED = 2; - - /** * Returns the translation language. * * @return \Drupal\Core\Language\LanguageInterface @@ -128,16 +113,4 @@ */ public function isTranslatable(); - /** - * Returns the translation status. - * - * @param string $langcode - * The language code identifying the translation. - * - * @return int|null - * One of the TRANSLATION_* constants or NULL if the given translation does - * not exist. - */ - public function getTranslationStatus($langcode); - } diff -u b/core/tests/Drupal/KernelTests/Core/Entity/EntityTranslationTest.php b/core/tests/Drupal/KernelTests/Core/Entity/EntityTranslationTest.php --- b/core/tests/Drupal/KernelTests/Core/Entity/EntityTranslationTest.php +++ b/core/tests/Drupal/KernelTests/Core/Entity/EntityTranslationTest.php @@ -4,7 +4,7 @@ use Drupal\Component\Utility\SafeMarkup; use Drupal\Core\Language\LanguageInterface; -use Drupal\Core\TypedData\TranslatableInterface; +use Drupal\Core\TypedData\TranslationStatusInterface; use Drupal\entity_test\Entity\EntityTestMulRev; use Drupal\field\Entity\FieldConfig; use Drupal\field\Entity\FieldStorageConfig; @@ -950,24 +950,24 @@ // Test that newly created entity has the translation status // TRANSLATION_CREATED. $entity = $storage->create($values); - $this->assertEquals(TranslatableInterface::TRANSLATION_CREATED, $entity->getTranslationStatus($entity->language()->getId())); + $this->assertEquals(TranslationStatusInterface::TRANSLATION_CREATED, $entity->getTranslationStatus($entity->language()->getId())); // Test that after saving a newly created entity it has the translation // status TRANSLATION_EXISTING. $entity->save(); - $this->assertEquals(TranslatableInterface::TRANSLATION_EXISTING, $entity->getTranslationStatus($entity->language()->getId())); + $this->assertEquals(TranslationStatusInterface::TRANSLATION_EXISTING, $entity->getTranslationStatus($entity->language()->getId())); // Test that after loading an existing entity it has the translation status // TRANSLATION_EXISTING. $storage->resetCache(); $entity = $storage->load($entity->id()); - $this->assertEquals(TranslatableInterface::TRANSLATION_EXISTING, $entity->getTranslationStatus($entity->language()->getId())); + $this->assertEquals(TranslationStatusInterface::TRANSLATION_EXISTING, $entity->getTranslationStatus($entity->language()->getId())); foreach ($this->langcodes as $key => $langcode) { // Test that after adding a new translation it has the translation status // TRANSLATION_CREATED. $entity->addTranslation($langcode, $values); - $this->assertEquals(TranslatableInterface::TRANSLATION_CREATED, $entity->getTranslationStatus($langcode)); + $this->assertEquals(TranslationStatusInterface::TRANSLATION_CREATED, $entity->getTranslationStatus($langcode)); // Test that after removing a newly added and not yet saved translation // it does not have any translation status for the removed translation. @@ -978,17 +978,17 @@ // the translation status TRANSLATION_EXISTING. $entity->addTranslation($langcode, $values) ->save(); - $this->assertEquals(TranslatableInterface::TRANSLATION_EXISTING, $entity->getTranslationStatus($langcode)); + $this->assertEquals(TranslationStatusInterface::TRANSLATION_EXISTING, $entity->getTranslationStatus($langcode)); // Test that after removing an existing translation its translation // status has changed to TRANSLATION_REMOVED. $entity->removeTranslation($langcode); - $this->assertEquals(TranslatableInterface::TRANSLATION_REMOVED, $entity->getTranslationStatus($langcode)); + $this->assertEquals(TranslationStatusInterface::TRANSLATION_REMOVED, $entity->getTranslationStatus($langcode)); // Test that after removing an existing translation and adding it again // its translation status has changed back to TRANSLATION_EXISTING. $entity->addTranslation($langcode, $values); - $this->assertEquals(TranslatableInterface::TRANSLATION_EXISTING, $entity->getTranslationStatus($langcode)); + $this->assertEquals(TranslationStatusInterface::TRANSLATION_EXISTING, $entity->getTranslationStatus($langcode)); // Test that after removing an existing translation and saving the entity // it does not have any translation status for the removed translation. @@ -1000,7 +1000,7 @@ // adding the translation again, the translation status of this // translation is TRANSLATION_CREATED. $entity->addTranslation($langcode, $values); - $this->assertEquals(TranslatableInterface::TRANSLATION_CREATED, $entity->getTranslationStatus($langcode)); + $this->assertEquals(TranslationStatusInterface::TRANSLATION_CREATED, $entity->getTranslationStatus($langcode)); $entity->save(); } @@ -1009,7 +1009,7 @@ $storage->resetCache(); $entity = $storage->load($entity->id()); foreach (array_keys($entity->getTranslationLanguages()) as $langcode) { - $this->assertEquals(TranslatableInterface::TRANSLATION_EXISTING, $entity->getTranslationStatus($langcode)); + $this->assertEquals(TranslationStatusInterface::TRANSLATION_EXISTING, $entity->getTranslationStatus($langcode)); } } only in patch2: unchanged: --- a/core/lib/Drupal/Core/Entity/ContentEntityInterface.php +++ b/core/lib/Drupal/Core/Entity/ContentEntityInterface.php @@ -3,6 +3,7 @@ namespace Drupal\Core\Entity; use Drupal\Core\TypedData\TranslatableInterface; +use Drupal\Core\TypedData\TranslationStatusInterface; /** * Defines a common interface for all content entity objects. @@ -20,7 +21,7 @@ * * @ingroup entity_api */ -interface ContentEntityInterface extends \Traversable, FieldableEntityInterface, RevisionableInterface, TranslatableInterface { +interface ContentEntityInterface extends \Traversable, FieldableEntityInterface, RevisionableInterface, TranslatableInterface, TranslationStatusInterface { /** * Determines if the current translation of the entity has unsaved changes. only in patch2: unchanged: --- /dev/null +++ b/core/lib/Drupal/Core/TypedData/TranslationStatusInterface.php @@ -0,0 +1,40 @@ +