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,7 +10,6 @@ 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; @@ -242,24 +241,28 @@ */ public function toArray() { $properties = array(); - try { - $id_key = $this->getEntityType()->getKey('id'); - foreach ($this->getPropertiesFromSchema() as $name) { - if ($name == $id_key) { - $properties[$name] = $this->id(); - } - else { - $properties[$name] = $this->get($name); - } - } + $config_name = $this->getEntityType()->getConfigPrefix() . '.' . $this->id(); + $definition = $this->getTypedConfig()->getDefinition($config_name); + if (isset($definition['mapping'])) { + $keys = array_keys($definition['mapping']); } - catch (SchemaIncompleteException $e) { - // Some configuration objects do not have a schema. Extract all key names - // from class properties. + 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); - $properties = array(); + $keys = array(); foreach ($class_info->getProperties(\ReflectionProperty::IS_PUBLIC) as $property) { - $name = $property->getName(); + $keys[] = $property->getName(); + } + } + $id_key = $this->getEntityType()->getKey('id'); + foreach ($keys as $name) { + if ($name == $id_key) { + $properties[$name] = $this->id(); + } + else { $properties[$name] = $this->get($name); } } @@ -267,23 +270,6 @@ } /** - * Gets the root properties of the configuration entity from its schema. - * - * @return array - * An array of property names. - * - * @throws \Exception - */ - protected function getPropertiesFromSchema() { - $config_name = $this->getEntityType()->getConfigPrefix() . '.' . $this->id(); - $definition = $this->getTypedConfig()->getDefinition($config_name); - if (!isset($definition['mapping'])) { - throw new SchemaIncompleteException(String::format('Missing root mapping definition in config schema for !name', array('!name' => $config_name))); - } - return array_keys($definition['mapping']); - } - - /** * Gets the typed config manager. * * @return \Drupal\Core\Config\TypedConfigManagerInterface