Commit 0f35ae9f authored by alexpott's avatar alexpott

Issue #2004336 by damiankloip: Default UUID key in ConfigEntityType.

parent 7abce708
......@@ -241,11 +241,7 @@ function entity_revision_delete($entity_type, $revision_id) {
function entity_load_by_uuid($entity_type_id, $uuid, $reset = FALSE) {
$entity_type = \Drupal::entityManager()->getDefinition($entity_type_id);
// Configuration entities do not use annotations to set the UUID key.
if ($entity_type->isSubclassOf('Drupal\Core\Config\Entity\ConfigEntityInterface')) {
$uuid_key = 'uuid';
}
elseif (!$uuid_key = $entity_type->getKey('uuid')) {
if (!$uuid_key = $entity_type->getKey('uuid')) {
throw new EntityStorageException("Entity type $entity_type_id does not support UUIDs.");
}
......
......@@ -174,11 +174,7 @@ public function isSyncing() {
* {@inheritdoc}
*/
public function createDuplicate() {
$duplicate = clone $this;
$duplicate->set($this->getEntityType()->getKey('id'), NULL);
// @todo Inject the UUID service into the Entity class once possible.
$duplicate->set('uuid', \Drupal::service('uuid')->generate());
$duplicate = parent::createDuplicate();
// Prevent the new duplicate from being misinterpreted as a rename.
$duplicate->setOriginalId(NULL);
......
......@@ -48,6 +48,15 @@ public function getConfigPrefix() {
return $this->provider . '.' . $config_prefix;
}
/**
* {@inheritdoc}
*/
public function getKeys() {
// Always add a default 'uuid' key.
return array('uuid' => 'uuid') + parent::getKeys();
}
/**
* {@inheritdoc}
*/
......
......@@ -48,13 +48,6 @@ class CustomBlockType extends ConfigEntityBase implements CustomBlockTypeInterfa
*/
public $id;
/**
* The custom block type UUID.
*
* @var string
*/
public $uuid;
/**
* The custom block type label.
*
......
......@@ -48,13 +48,6 @@ class Block extends ConfigEntityBase implements BlockInterface, EntityWithPlugin
*/
public $id;
/**
* The block UUID.
*
* @var string
*/
public $uuid;
/**
* The plugin instance settings.
*
......
......@@ -51,13 +51,6 @@ class Breakpoint extends ConfigEntityBase implements BreakpointInterface {
*/
public $id;
/**
* The breakpoint UUID.
*
* @var string
*/
public $uuid;
/**
* The breakpoint name (machine name) as specified by theme or module.
*
......
......@@ -33,13 +33,6 @@ class BreakpointGroup extends ConfigEntityBase implements BreakpointGroupInterfa
*/
public $id;
/**
* The breakpoint group UUID.
*
* @var string
*/
public $uuid;
/**
* The breakpoint group machine name.
*
......
......@@ -52,11 +52,11 @@ function testImport() {
// Create new config entity.
$original_dynamic_data = array(
'id' => 'new',
'uuid' => '30df59bd-7b03-4cf7-bb35-d42fc49f0651',
'label' => 'New',
'weight' => 0,
'style' => '',
'status' => TRUE,
'uuid' => '30df59bd-7b03-4cf7-bb35-d42fc49f0651',
'langcode' => language_default()->id,
'protected_property' => '',
);
......
......@@ -163,11 +163,11 @@ function testNew() {
// Create new config entity.
$original_dynamic_data = array(
'id' => 'new',
'uuid' => '30df59bd-7b03-4cf7-bb35-d42fc49f0651',
'label' => 'New',
'weight' => 0,
'style' => '',
'status' => TRUE,
'uuid' => '30df59bd-7b03-4cf7-bb35-d42fc49f0651',
'langcode' => language_default()->id,
'protected_property' => '',
);
......
......@@ -48,13 +48,6 @@ class ConfigTest extends ConfigEntityBase implements ConfigTestInterface {
*/
public $id;
/**
* The UUID for the configuration entity.
*
* @var string
*/
public $uuid;
/**
* The human-readable name of the configuration entity.
*
......
......@@ -48,13 +48,6 @@ class Category extends ConfigEntityBase implements CategoryInterface {
*/
public $id;
/**
* The category UUID.
*
* @var string
*/
public $uuid;
/**
* The category label.
*
......
......@@ -24,13 +24,6 @@ abstract class EntityDisplayBase extends ConfigEntityBase implements EntityDispl
*/
public $id;
/**
* Unique UUID for the config entity.
*
* @var string
*/
public $uuid;
/**
* Entity type to be displayed.
*
......
......@@ -21,13 +21,6 @@ abstract class EntityDisplayModeBase extends ConfigEntityBase implements EntityD
*/
public $id;
/**
* The UUID of the form or view mode.
*
* @var string
*/
public $uuid;
/**
* The human-readable name of the form or view mode.
*
......
......@@ -65,15 +65,6 @@ class FieldConfig extends ConfigEntityBase implements FieldConfigInterface {
*/
public $name;
/**
* The field UUID.
*
* This is assigned automatically when the field is created.
*
* @var string
*/
public $uuid;
/**
* The name of the entity type the field can be attached to.
*
......
......@@ -44,15 +44,6 @@ class FieldInstanceConfig extends ConfigEntityBase implements FieldInstanceConfi
*/
public $id;
/**
* The instance UUID.
*
* This is assigned automatically when the instance is created.
*
* @var string
*/
public $uuid;
/**
* The name of the field attached to the bundle by this instance.
*
......
......@@ -68,13 +68,6 @@ class FilterFormat extends ConfigEntityBase implements FilterFormatInterface, En
*/
public $name;
/**
* The UUID for this entity.
*
* @var string
*/
public $uuid;
/**
* Weight of this format in the text format selector.
*
......
......@@ -68,13 +68,6 @@ class ImageStyle extends ConfigEntityBase implements ImageStyleInterface, Entity
*/
public $label;
/**
* The UUID for this entity.
*
* @var string
*/
public $uuid;
/**
* The array of image effects for this image style.
*
......
......@@ -49,15 +49,6 @@ class Language extends ConfigEntityBase implements LanguageInterface {
*/
public $id;
/**
* The language UUID.
*
* This is assigned automatically when the language is created.
*
* @var string
*/
public $uuid;
/**
* The human-readable label for the language.
*
......
......@@ -45,15 +45,6 @@ class Migration extends ConfigEntityBase implements MigrationInterface {
*/
public $id;
/**
* The migration UUID.
*
* This is assigned automatically when the migration is created.
*
* @var string
*/
public $uuid;
/**
* The human-readable label for the migration.
*
......
......@@ -53,13 +53,6 @@ class NodeType extends ConfigEntityBase implements NodeTypeInterface {
*/
public $type;
/**
* The UUID of the node type.
*
* @var string
*/
public $uuid;
/**
* The human-readable name of the node type.
*
......
......@@ -47,13 +47,6 @@ class PictureMapping extends ConfigEntityBase implements PictureMappingInterface
*/
public $id;
/**
* The picture UUID.
*
* @var string
*/
public $uuid;
/**
* The picture label.
*
......
......@@ -32,13 +32,6 @@ class RdfMapping extends ConfigEntityBase implements RdfMappingInterface {
*/
public $id;
/**
* UUID for the config entity.
*
* @var string
*/
public $uuid;
/**
* Entity type to be mapped.
*
......
......@@ -65,13 +65,6 @@ class SearchPage extends ConfigEntityBase implements SearchPageInterface, Entity
*/
public $label;
/**
* The UUID of the search page entity.
*
* @var string
*/
public $uuid;
/**
* The configuration of the search page entity.
*
......
......@@ -51,13 +51,6 @@ class ShortcutSet extends ConfigEntityBase implements ShortcutSetInterface {
*/
public $id;
/**
* The UUID for the configuration entity.
*
* @var string
*/
public $uuid;
/**
* The human-readable name of the configuration entity.
*
......
......@@ -42,13 +42,6 @@ class Action extends ConfigEntityBase implements ActionConfigEntityInterface, En
*/
public $label;
/**
* The UUID of the action.
*
* @var string
*/
public $uuid;
/**
* The action type.
*
......
......@@ -47,13 +47,6 @@ class DateFormat extends ConfigEntityBase implements DateFormatInterface {
*/
public $id;
/**
* The date format UUID.
*
* @var string
*/
public $uuid;
/**
* The human-readable name of the date format entity.
*
......
......@@ -37,13 +37,6 @@ class Menu extends ConfigEntityBase implements MenuInterface {
*/
public $id;
/**
* The menu UUID.
*
* @var string
*/
public $uuid;
/**
* The human-readable name of the menu entity.
*
......
......@@ -53,13 +53,6 @@ class Vocabulary extends ConfigEntityBase implements VocabularyInterface {
*/
public $vid;
/**
* The vocabulary UUID.
*
* @var string
*/
public $uuid;
/**
* Name of the vocabulary.
*
......
......@@ -50,13 +50,6 @@ class Role extends ConfigEntityBase implements RoleInterface {
*/
public $id;
/**
* The UUID of this role.
*
* @var string
*/
public $uuid;
/**
* The human-readable label of this role.
*
......
......@@ -95,13 +95,6 @@ class View extends ConfigEntityBase implements ViewStorageInterface {
*/
protected $base_field = 'nid';
/**
* The UUID for this entity.
*
* @var string
*/
public $uuid = NULL;
/**
* Stores a reference to the executable version of this view.
*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment