diff -u b/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php b/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php --- b/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php +++ b/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php @@ -10,6 +10,7 @@ use Drupal\Component\Plugin\ConfigurablePluginInterface; use Drupal\Component\Utility\String; use Drupal\Core\Cache\Cache; +use Drupal\Core\Config\Schema\SchemaIncompleteException; use Drupal\Core\Entity\Entity; use Drupal\Core\Config\ConfigDuplicateUUIDException; use Drupal\Core\Entity\EntityStorageInterface; @@ -243,22 +244,13 @@ $properties = array(); $config_name = $this->getEntityType()->getConfigPrefix() . '.' . $this->id(); $definition = $this->getTypedConfig()->getDefinition($config_name); - if (isset($definition['mapping'])) { - $keys = array_keys($definition['mapping']); - } - else { - // Some configuration objects do not have a schema. Extract key names from - // class properties. - // @todo Remove once migration config entities have schema - // https://drupal.org/node/2183957. - $class_info = new \ReflectionClass($this); - $keys = array(); - foreach ($class_info->getProperties(\ReflectionProperty::IS_PUBLIC) as $property) { - $keys[] = $property->getName(); - } + if (!isset($definition['mapping'])) { + throw new SchemaIncompleteException(String::format('Incomplete or missing schema for @config_name', array('@config_name' => $config_name))); } $id_key = $this->getEntityType()->getKey('id'); - foreach ($keys as $name) { + foreach (array_keys($definition['mapping']) as $name) { + // Special handling for IDs so that computed compound IDs work. + // @see \Drupal\entity\EntityDisplayBase::id() if ($name == $id_key) { $properties[$name] = $this->id(); } diff -u b/core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityBaseUnitTest.php b/core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityBaseUnitTest.php --- b/core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityBaseUnitTest.php +++ b/core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityBaseUnitTest.php @@ -451,17 +451,11 @@ /** * @covers ::toArray + * + * @expectedException \Drupal\Core\Config\Schema\SchemaIncompleteException */ public function testToArrayFallback() { - $properties = $this->entity->toArray(); - $this->assertInternalType('array', $properties); - $class_info = new \ReflectionClass($this->entity); - foreach ($class_info->getProperties(\ReflectionProperty::IS_PUBLIC) as $property) { - $name = $property->getName(); - $this->assertArrayHasKey($name, $properties); - $this->assertSame($this->entity->get($name), $properties[$name]); - } - $this->assertArrayNotHasKey('dependencies', $properties); + $this->entity->toArray(); } } diff -u b/core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityStorageTest.php b/core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityStorageTest.php --- b/core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityStorageTest.php +++ b/core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityStorageTest.php @@ -175,7 +175,9 @@ $this->cacheBackend = $this->getMock('Drupal\Core\Cache\CacheBackendInterface'); $this->typedConfigManager = $this->getMock('Drupal\Core\Config\TypedConfigManagerInterface'); - + $this->typedConfigManager->expects($this->any()) + ->method('getDefinition') + ->will($this->returnValue(array('mapping' => array('id' => '', 'uuid' => '', 'dependencies' => '')))); $container = new ContainerBuilder(); $container->set('entity.manager', $this->entityManager); $container->set('config.typed', $this->typedConfigManager); only in patch2: unchanged: --- a/core/modules/migrate/lib/Drupal/migrate/Entity/Migration.php +++ b/core/modules/migrate/lib/Drupal/migrate/Entity/Migration.php @@ -339,4 +339,18 @@ public function checkRequirements() { return TRUE; } + /** + * {@inheritdoc} + */ + public function toArray() { + // @todo Remove once migration config entities have schema + // https://drupal.org/node/2183957. + $class_info = new \ReflectionClass($this); + foreach ($class_info->getProperties(\ReflectionProperty::IS_PUBLIC) as $property) { + $name = $property->getName(); + $properties[$name] = $this->get($name); + } + return $properties; + } + }