diff --git a/core/modules/config_translation/src/ConfigEntityMapper.php b/core/modules/config_translation/src/ConfigEntityMapper.php index 4a6d275..fd0b353 100644 --- a/core/modules/config_translation/src/ConfigEntityMapper.php +++ b/core/modules/config_translation/src/ConfigEntityMapper.php @@ -117,6 +117,16 @@ public function populateFromRequest(Request $request) { } /** + * Gets the entity instance for this mapper. + * + * @return \Drupal\Core\Config\Entity\ConfigEntityInterface $entity + * The configuration entity. + */ + public function getEntity() { + return $this->entity; + } + + /** * Sets the entity instance for this mapper. * * This method can only be invoked when the concrete entity is known, that is diff --git a/core/modules/config_translation/tests/src/Unit/ConfigEntityMapperTest.php b/core/modules/config_translation/tests/src/Unit/ConfigEntityMapperTest.php index 8041931..e473cd2 100644 --- a/core/modules/config_translation/tests/src/Unit/ConfigEntityMapperTest.php +++ b/core/modules/config_translation/tests/src/Unit/ConfigEntityMapperTest.php @@ -99,6 +99,31 @@ protected function setUp() { } /** + * Tests ConfigEntityMapper::getOperations(). + */ + public function testGetEntity() { + $result = $this->configEntityMapper->getEntity(); + $this->assertEquals(NULL, $result); + + $entity_type = $this->getMock('Drupal\Core\Config\Entity\ConfigEntityTypeInterface'); + $entity_type + ->expects($this->any()) + ->method('getConfigPrefix') + ->will($this->returnValue('config_prefix')); + + $this->entityManager + ->expects($this->once()) + ->method('getDefinition') + ->with('configurable_language') + ->will($this->returnValue($entity_type)); + + $this->configEntityMapper->setEntity($this->entity); + $result = $this->configEntityMapper->getEntity(); + $expected = $this->entity; + $this->assertEquals($expected, $result); + } + + /** * Tests ConfigEntityMapper::setEntity(). */ public function testSetEntity() {