summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Pott2014-03-08 10:58:15 (GMT)
committerAlex Pott2014-03-08 10:58:15 (GMT)
commit0f35ae9f75e91ec52d043907961912136bfba36b (patch)
tree056200b7bf56329e004d4f7fe88844c1a6d8044f
parent7abce708dcb094d7fd70d078448a41c7fd850739 (diff)
Issue #2004336 by damiankloip: Default UUID key in ConfigEntityType.
-rw-r--r--core/includes/entity.inc6
-rw-r--r--core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php6
-rw-r--r--core/lib/Drupal/Core/Config/Entity/ConfigEntityType.php9
-rw-r--r--core/modules/block/custom_block/lib/Drupal/custom_block/Entity/CustomBlockType.php7
-rw-r--r--core/modules/block/lib/Drupal/block/Entity/Block.php7
-rw-r--r--core/modules/breakpoint/lib/Drupal/breakpoint/Entity/Breakpoint.php7
-rw-r--r--core/modules/breakpoint/lib/Drupal/breakpoint/Entity/BreakpointGroup.php7
-rw-r--r--core/modules/config/lib/Drupal/config/Tests/ConfigImportUITest.php2
-rw-r--r--core/modules/config/lib/Drupal/config/Tests/ConfigImporterTest.php2
-rw-r--r--core/modules/config/tests/config_test/lib/Drupal/config_test/Entity/ConfigTest.php7
-rw-r--r--core/modules/contact/lib/Drupal/contact/Entity/Category.php7
-rw-r--r--core/modules/entity/lib/Drupal/entity/EntityDisplayBase.php7
-rw-r--r--core/modules/entity/lib/Drupal/entity/EntityDisplayModeBase.php7
-rw-r--r--core/modules/field/lib/Drupal/field/Entity/FieldConfig.php9
-rw-r--r--core/modules/field/lib/Drupal/field/Entity/FieldInstanceConfig.php9
-rw-r--r--core/modules/filter/lib/Drupal/filter/Entity/FilterFormat.php7
-rw-r--r--core/modules/image/lib/Drupal/image/Entity/ImageStyle.php7
-rw-r--r--core/modules/language/lib/Drupal/language/Entity/Language.php9
-rw-r--r--core/modules/migrate/lib/Drupal/migrate/Entity/Migration.php9
-rw-r--r--core/modules/node/lib/Drupal/node/Entity/NodeType.php7
-rw-r--r--core/modules/picture/lib/Drupal/picture/Entity/PictureMapping.php7
-rw-r--r--core/modules/rdf/lib/Drupal/rdf/Entity/RdfMapping.php7
-rw-r--r--core/modules/search/lib/Drupal/search/Entity/SearchPage.php7
-rw-r--r--core/modules/shortcut/lib/Drupal/shortcut/Entity/ShortcutSet.php7
-rw-r--r--core/modules/system/lib/Drupal/system/Entity/Action.php7
-rw-r--r--core/modules/system/lib/Drupal/system/Entity/DateFormat.php7
-rw-r--r--core/modules/system/lib/Drupal/system/Entity/Menu.php7
-rw-r--r--core/modules/taxonomy/lib/Drupal/taxonomy/Entity/Vocabulary.php7
-rw-r--r--core/modules/user/lib/Drupal/user/Entity/Role.php7
-rw-r--r--core/modules/views/lib/Drupal/views/Entity/View.php7
30 files changed, 13 insertions, 195 deletions
diff --git a/core/includes/entity.inc b/core/includes/entity.inc
index fa5f370..51b0f79 100644
--- a/core/includes/entity.inc
+++ b/core/includes/entity.inc
@@ -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.");
}
diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php b/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php
index 87b43f7..18e0260 100644
--- a/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php
+++ b/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php
@@ -174,11 +174,7 @@ abstract class ConfigEntityBase extends Entity implements ConfigEntityInterface
* {@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);
diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigEntityType.php b/core/lib/Drupal/Core/Config/Entity/ConfigEntityType.php
index e8f8088..9a61693 100644
--- a/core/lib/Drupal/Core/Config/Entity/ConfigEntityType.php
+++ b/core/lib/Drupal/Core/Config/Entity/ConfigEntityType.php
@@ -51,6 +51,15 @@ class ConfigEntityType extends EntityType {
/**
* {@inheritdoc}
*/
+ public function getKeys() {
+ // Always add a default 'uuid' key.
+ return array('uuid' => 'uuid') + parent::getKeys();
+ }
+
+
+ /**
+ * {@inheritdoc}
+ */
public function getBaseTable() {
return FALSE;
}
diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/Entity/CustomBlockType.php b/core/modules/block/custom_block/lib/Drupal/custom_block/Entity/CustomBlockType.php
index 48bef95..59a4735 100644
--- a/core/modules/block/custom_block/lib/Drupal/custom_block/Entity/CustomBlockType.php
+++ b/core/modules/block/custom_block/lib/Drupal/custom_block/Entity/CustomBlockType.php
@@ -49,13 +49,6 @@ class CustomBlockType extends ConfigEntityBase implements CustomBlockTypeInterfa
public $id;
/**
- * The custom block type UUID.
- *
- * @var string
- */
- public $uuid;
-
- /**
* The custom block type label.
*
* @var string
diff --git a/core/modules/block/lib/Drupal/block/Entity/Block.php b/core/modules/block/lib/Drupal/block/Entity/Block.php
index c0d4de9..cb49cac 100644
--- a/core/modules/block/lib/Drupal/block/Entity/Block.php
+++ b/core/modules/block/lib/Drupal/block/Entity/Block.php
@@ -49,13 +49,6 @@ class Block extends ConfigEntityBase implements BlockInterface, EntityWithPlugin
public $id;
/**
- * The block UUID.
- *
- * @var string
- */
- public $uuid;
-
- /**
* The plugin instance settings.
*
* @var array
diff --git a/core/modules/breakpoint/lib/Drupal/breakpoint/Entity/Breakpoint.php b/core/modules/breakpoint/lib/Drupal/breakpoint/Entity/Breakpoint.php
index 08ae4b6..02c1945 100644
--- a/core/modules/breakpoint/lib/Drupal/breakpoint/Entity/Breakpoint.php
+++ b/core/modules/breakpoint/lib/Drupal/breakpoint/Entity/Breakpoint.php
@@ -52,13 +52,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.
*
* @var string
diff --git a/core/modules/breakpoint/lib/Drupal/breakpoint/Entity/BreakpointGroup.php b/core/modules/breakpoint/lib/Drupal/breakpoint/Entity/BreakpointGroup.php
index f3807af..80f10e0 100644
--- a/core/modules/breakpoint/lib/Drupal/breakpoint/Entity/BreakpointGroup.php
+++ b/core/modules/breakpoint/lib/Drupal/breakpoint/Entity/BreakpointGroup.php
@@ -34,13 +34,6 @@ class BreakpointGroup extends ConfigEntityBase implements BreakpointGroupInterfa
public $id;
/**
- * The breakpoint group UUID.
- *
- * @var string
- */
- public $uuid;
-
- /**
* The breakpoint group machine name.
*
* @var string
diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigImportUITest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigImportUITest.php
index 24be35e..89413d2 100644
--- a/core/modules/config/lib/Drupal/config/Tests/ConfigImportUITest.php
+++ b/core/modules/config/lib/Drupal/config/Tests/ConfigImportUITest.php
@@ -52,11 +52,11 @@ class ConfigImportUITest extends WebTestBase {
// 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' => '',
);
diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigImporterTest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigImporterTest.php
index f23cdcb..b597aa7 100644
--- a/core/modules/config/lib/Drupal/config/Tests/ConfigImporterTest.php
+++ b/core/modules/config/lib/Drupal/config/Tests/ConfigImporterTest.php
@@ -163,11 +163,11 @@ class ConfigImporterTest extends DrupalUnitTestBase {
// 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' => '',
);
diff --git a/core/modules/config/tests/config_test/lib/Drupal/config_test/Entity/ConfigTest.php b/core/modules/config/tests/config_test/lib/Drupal/config_test/Entity/ConfigTest.php
index 1bb4deb..029a7ac 100644
--- a/core/modules/config/tests/config_test/lib/Drupal/config_test/Entity/ConfigTest.php
+++ b/core/modules/config/tests/config_test/lib/Drupal/config_test/Entity/ConfigTest.php
@@ -49,13 +49,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.
*
* @var string
diff --git a/core/modules/contact/lib/Drupal/contact/Entity/Category.php b/core/modules/contact/lib/Drupal/contact/Entity/Category.php
index b2f2460..a2fe218 100644
--- a/core/modules/contact/lib/Drupal/contact/Entity/Category.php
+++ b/core/modules/contact/lib/Drupal/contact/Entity/Category.php
@@ -49,13 +49,6 @@ class Category extends ConfigEntityBase implements CategoryInterface {
public $id;
/**
- * The category UUID.
- *
- * @var string
- */
- public $uuid;
-
- /**
* The category label.
*
* @var string
diff --git a/core/modules/entity/lib/Drupal/entity/EntityDisplayBase.php b/core/modules/entity/lib/Drupal/entity/EntityDisplayBase.php
index 93d132d..150b73b 100644
--- a/core/modules/entity/lib/Drupal/entity/EntityDisplayBase.php
+++ b/core/modules/entity/lib/Drupal/entity/EntityDisplayBase.php
@@ -25,13 +25,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.
*
* @var string
diff --git a/core/modules/entity/lib/Drupal/entity/EntityDisplayModeBase.php b/core/modules/entity/lib/Drupal/entity/EntityDisplayModeBase.php
index 1541143..6705f03 100644
--- a/core/modules/entity/lib/Drupal/entity/EntityDisplayModeBase.php
+++ b/core/modules/entity/lib/Drupal/entity/EntityDisplayModeBase.php
@@ -22,13 +22,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.
*
* @var string
diff --git a/core/modules/field/lib/Drupal/field/Entity/FieldConfig.php b/core/modules/field/lib/Drupal/field/Entity/FieldConfig.php
index 3388c95..9e8adee 100644
--- a/core/modules/field/lib/Drupal/field/Entity/FieldConfig.php
+++ b/core/modules/field/lib/Drupal/field/Entity/FieldConfig.php
@@ -66,15 +66,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.
*
* @var string
diff --git a/core/modules/field/lib/Drupal/field/Entity/FieldInstanceConfig.php b/core/modules/field/lib/Drupal/field/Entity/FieldInstanceConfig.php
index e61896a..cd78415 100644
--- a/core/modules/field/lib/Drupal/field/Entity/FieldInstanceConfig.php
+++ b/core/modules/field/lib/Drupal/field/Entity/FieldInstanceConfig.php
@@ -45,15 +45,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.
*
* @var string
diff --git a/core/modules/filter/lib/Drupal/filter/Entity/FilterFormat.php b/core/modules/filter/lib/Drupal/filter/Entity/FilterFormat.php
index 09e098f..4e6febf 100644
--- a/core/modules/filter/lib/Drupal/filter/Entity/FilterFormat.php
+++ b/core/modules/filter/lib/Drupal/filter/Entity/FilterFormat.php
@@ -69,13 +69,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.
*
* The first/lowest text format that is accessible for a user is used as
diff --git a/core/modules/image/lib/Drupal/image/Entity/ImageStyle.php b/core/modules/image/lib/Drupal/image/Entity/ImageStyle.php
index ab7480b..0251354 100644
--- a/core/modules/image/lib/Drupal/image/Entity/ImageStyle.php
+++ b/core/modules/image/lib/Drupal/image/Entity/ImageStyle.php
@@ -69,13 +69,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.
*
* @var array
diff --git a/core/modules/language/lib/Drupal/language/Entity/Language.php b/core/modules/language/lib/Drupal/language/Entity/Language.php
index 7c92351..c7ad236 100644
--- a/core/modules/language/lib/Drupal/language/Entity/Language.php
+++ b/core/modules/language/lib/Drupal/language/Entity/Language.php
@@ -50,15 +50,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.
*
* @var string
diff --git a/core/modules/migrate/lib/Drupal/migrate/Entity/Migration.php b/core/modules/migrate/lib/Drupal/migrate/Entity/Migration.php
index 3967aec..587c888 100644
--- a/core/modules/migrate/lib/Drupal/migrate/Entity/Migration.php
+++ b/core/modules/migrate/lib/Drupal/migrate/Entity/Migration.php
@@ -46,15 +46,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.
*
* @var string
diff --git a/core/modules/node/lib/Drupal/node/Entity/NodeType.php b/core/modules/node/lib/Drupal/node/Entity/NodeType.php
index d8e413b..d7fd3b0 100644
--- a/core/modules/node/lib/Drupal/node/Entity/NodeType.php
+++ b/core/modules/node/lib/Drupal/node/Entity/NodeType.php
@@ -54,13 +54,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.
*
* @var string
diff --git a/core/modules/picture/lib/Drupal/picture/Entity/PictureMapping.php b/core/modules/picture/lib/Drupal/picture/Entity/PictureMapping.php
index ba1351d..aa8b332 100644
--- a/core/modules/picture/lib/Drupal/picture/Entity/PictureMapping.php
+++ b/core/modules/picture/lib/Drupal/picture/Entity/PictureMapping.php
@@ -48,13 +48,6 @@ class PictureMapping extends ConfigEntityBase implements PictureMappingInterface
public $id;
/**
- * The picture UUID.
- *
- * @var string
- */
- public $uuid;
-
- /**
* The picture label.
*
* @var string
diff --git a/core/modules/rdf/lib/Drupal/rdf/Entity/RdfMapping.php b/core/modules/rdf/lib/Drupal/rdf/Entity/RdfMapping.php
index 1916320..2256dd4 100644
--- a/core/modules/rdf/lib/Drupal/rdf/Entity/RdfMapping.php
+++ b/core/modules/rdf/lib/Drupal/rdf/Entity/RdfMapping.php
@@ -33,13 +33,6 @@ class RdfMapping extends ConfigEntityBase implements RdfMappingInterface {
public $id;
/**
- * UUID for the config entity.
- *
- * @var string
- */
- public $uuid;
-
- /**
* Entity type to be mapped.
*
* @var string
diff --git a/core/modules/search/lib/Drupal/search/Entity/SearchPage.php b/core/modules/search/lib/Drupal/search/Entity/SearchPage.php
index b992a76..36444e0 100644
--- a/core/modules/search/lib/Drupal/search/Entity/SearchPage.php
+++ b/core/modules/search/lib/Drupal/search/Entity/SearchPage.php
@@ -66,13 +66,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.
*
* @var array
diff --git a/core/modules/shortcut/lib/Drupal/shortcut/Entity/ShortcutSet.php b/core/modules/shortcut/lib/Drupal/shortcut/Entity/ShortcutSet.php
index ce52aca..8e4381a 100644
--- a/core/modules/shortcut/lib/Drupal/shortcut/Entity/ShortcutSet.php
+++ b/core/modules/shortcut/lib/Drupal/shortcut/Entity/ShortcutSet.php
@@ -52,13 +52,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.
*
* @var string
diff --git a/core/modules/system/lib/Drupal/system/Entity/Action.php b/core/modules/system/lib/Drupal/system/Entity/Action.php
index 972b4a3..93b38f1 100644
--- a/core/modules/system/lib/Drupal/system/Entity/Action.php
+++ b/core/modules/system/lib/Drupal/system/Entity/Action.php
@@ -43,13 +43,6 @@ class Action extends ConfigEntityBase implements ActionConfigEntityInterface, En
public $label;
/**
- * The UUID of the action.
- *
- * @var string
- */
- public $uuid;
-
- /**
* The action type.
*
* @var string
diff --git a/core/modules/system/lib/Drupal/system/Entity/DateFormat.php b/core/modules/system/lib/Drupal/system/Entity/DateFormat.php
index 71c2451..ce169b9 100644
--- a/core/modules/system/lib/Drupal/system/Entity/DateFormat.php
+++ b/core/modules/system/lib/Drupal/system/Entity/DateFormat.php
@@ -48,13 +48,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.
*
* @var string
diff --git a/core/modules/system/lib/Drupal/system/Entity/Menu.php b/core/modules/system/lib/Drupal/system/Entity/Menu.php
index e8aecff..b4abf10 100644
--- a/core/modules/system/lib/Drupal/system/Entity/Menu.php
+++ b/core/modules/system/lib/Drupal/system/Entity/Menu.php
@@ -38,13 +38,6 @@ class Menu extends ConfigEntityBase implements MenuInterface {
public $id;
/**
- * The menu UUID.
- *
- * @var string
- */
- public $uuid;
-
- /**
* The human-readable name of the menu entity.
*
* @var string
diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Entity/Vocabulary.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Entity/Vocabulary.php
index c9bf8b6..ee3d8f3 100644
--- a/core/modules/taxonomy/lib/Drupal/taxonomy/Entity/Vocabulary.php
+++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Entity/Vocabulary.php
@@ -54,13 +54,6 @@ class Vocabulary extends ConfigEntityBase implements VocabularyInterface {
public $vid;
/**
- * The vocabulary UUID.
- *
- * @var string
- */
- public $uuid;
-
- /**
* Name of the vocabulary.
*
* @var string
diff --git a/core/modules/user/lib/Drupal/user/Entity/Role.php b/core/modules/user/lib/Drupal/user/Entity/Role.php
index 49152e3..2a025d9 100644
--- a/core/modules/user/lib/Drupal/user/Entity/Role.php
+++ b/core/modules/user/lib/Drupal/user/Entity/Role.php
@@ -51,13 +51,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.
*
* @var string
diff --git a/core/modules/views/lib/Drupal/views/Entity/View.php b/core/modules/views/lib/Drupal/views/Entity/View.php
index 62e5536..8eea4c1 100644
--- a/core/modules/views/lib/Drupal/views/Entity/View.php
+++ b/core/modules/views/lib/Drupal/views/Entity/View.php
@@ -96,13 +96,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.
*
* @var \Drupal\views\ViewExecutable