Commit b0da3ae6 authored by alexpott's avatar alexpott

Issue #2119905 by damiankloip, tim.plunkett, Berdir: Provide @ConfigEntityType...

Issue #2119905 by damiankloip, tim.plunkett, Berdir: Provide @ConfigEntityType and @ContentEntityType to have better defaults.
parent 4022a548
<?php
/**
* @file
* Contains \Drupal\Core\Config\Entity\ConfigEntityType.
*/
namespace Drupal\Core\Config\Entity;
use Drupal\Core\Entity\EntityType;
/**
* Provides an implementation of a config entity type and its metadata.
*/
class ConfigEntityType extends EntityType {
/**
* Returns the config prefix used by the configuration entity type.
*
* @var string
*/
protected $config_prefix;
/**
* {@inheritdoc}
*/
public function getControllerClasses() {
return parent::getControllerClasses() + array(
'storage' => 'Drupal\Core\Config\Entity\ConfigStorageController',
);
}
/**
* {@inheritdoc}
*/
public function getConfigPrefix() {
return isset($this->config_prefix) ? $this->config_prefix : FALSE;
}
/**
* {@inheritdoc}
*/
public function getBaseTable() {
return FALSE;
}
/**
* {@inheritdoc}
*/
public function getRevisionDataTable() {
return FALSE;
}
/**
* {@inheritdoc}
*/
public function getRevisionTable() {
return FALSE;
}
/**
* {@inheritdoc}
*/
public function getDataTable() {
return FALSE;
}
}
<?php
/**
* @file
* Contains \Drupal\Core\Entity\Annotation\ConfigEntityType.
*/
namespace Drupal\Core\Entity\Annotation;
/**
* Defines a config entity type annotation object.
*
* @Annotation
*/
class ConfigEntityType extends EntityType {
/**
* {@inheritdoc}
*/
public $entity_type_class = 'Drupal\Core\Config\Entity\ConfigEntityType';
}
<?php
/**
* @file
* Contains \Drupal\Core\Entity\Annotation\ContentEntityType.
*/
namespace Drupal\Core\Entity\Annotation;
/**
* Defines a content entity type annotation object.
*
* @Annotation
*/
class ContentEntityType extends EntityType {
/**
* {@inheritdoc}
*/
public $entity_type_class = 'Drupal\Core\Entity\ContentEntityType';
}
<?php
/**
* @file
* Contains \Drupal\Core\Entity\ContentEntityType.
*/
namespace Drupal\Core\Entity;
/**
* Defines a config entity type annotation object.
*/
class ContentEntityType extends EntityType {
/**
* {@inheritdoc}
*/
public function getControllerClasses() {
return parent::getControllerClasses() + array(
'storage' => 'Drupal\Core\Entity\FieldableDatabaseStorageController',
);
}
/**
* {@inheritdoc}
*/
public function getConfigPrefix() {
return FALSE;
}
}
......@@ -163,13 +163,6 @@ class EntityType implements EntityTypeInterface {
*/
protected $translatable = FALSE;
/**
* Returns the config prefix used by the configuration entity type.
*
* @var string
*/
protected $config_prefix;
/**
* The human-readable name of the type.
*
......@@ -541,7 +534,7 @@ public function isTranslatable() {
* {@inheritdoc}
*/
public function getConfigPrefix() {
return isset($this->config_prefix) ? $this->config_prefix : FALSE;
return FALSE;
}
/**
......
......@@ -16,7 +16,7 @@
/**
* Defines the aggregator feed entity class.
*
* @EntityType(
* @ContentEntityType(
* id = "aggregator_feed",
* label = @Translation("Aggregator feed"),
* controllers = {
......
......@@ -15,7 +15,7 @@
/**
* Defines the aggregator item entity class.
*
* @EntityType(
* @ContentEntityType(
* id = "aggregator_item",
* label = @Translation("Aggregator feed item"),
* controllers = {
......
......@@ -15,12 +15,11 @@
/**
* Defines the custom block entity class.
*
* @EntityType(
* @ContentEntityType(
* id = "custom_block",
* label = @Translation("Custom Block"),
* bundle_label = @Translation("Custom Block type"),
* controllers = {
* "storage" = "Drupal\Core\Entity\FieldableDatabaseStorageController",
* "access" = "Drupal\custom_block\CustomBlockAccessController",
* "list" = "Drupal\custom_block\CustomBlockListController",
* "view_builder" = "Drupal\custom_block\CustomBlockViewBuilder",
......
......@@ -14,11 +14,10 @@
/**
* Defines the custom block type entity.
*
* @EntityType(
* @ConfigEntityType(
* id = "custom_block_type",
* label = @Translation("Custom block type"),
* controllers = {
* "storage" = "Drupal\Core\Config\Entity\ConfigStorageController",
* "form" = {
* "default" = "Drupal\custom_block\CustomBlockTypeFormController",
* "add" = "Drupal\custom_block\CustomBlockTypeFormController",
......
......@@ -15,11 +15,10 @@
/**
* Defines a Block configuration entity class.
*
* @EntityType(
* @ConfigEntityType(
* id = "block",
* label = @Translation("Block"),
* controllers = {
* "storage" = "Drupal\Core\Config\Entity\ConfigStorageController",
* "access" = "Drupal\block\BlockAccessController",
* "view_builder" = "Drupal\block\BlockViewBuilder",
* "list" = "Drupal\block\BlockListController",
......
......@@ -18,12 +18,9 @@
/**
* Defines the Breakpoint entity.
*
* @EntityType(
* @ConfigEntityType(
* id = "breakpoint",
* label = @Translation("Breakpoint"),
* controllers = {
* "storage" = "Drupal\Core\Config\Entity\ConfigStorageController"
* },
* config_prefix = "breakpoint.breakpoint",
* entity_keys = {
* "id" = "id",
......
......@@ -15,12 +15,9 @@
/**
* Defines the BreakpointGroup entity.
*
* @EntityType(
* @ConfigEntityType(
* id = "breakpoint_group",
* label = @Translation("Breakpoint group"),
* controllers = {
* "storage" = "Drupal\Core\Config\Entity\ConfigStorageController"
* },
* config_prefix = "breakpoint.breakpoint_group",
* entity_keys = {
* "id" = "id",
......
......@@ -19,7 +19,7 @@
/**
* Defines the comment entity class.
*
* @EntityType(
* @ContentEntityType(
* id = "comment",
* label = @Translation("Comment"),
* bundle_label = @Translation("Content type"),
......
......@@ -10,7 +10,7 @@
/**
* Defines the ConfigQueryTest configuration entity used by the query test.
*
* @EntityType(
* @ConfigEntityType(
* id = "config_query_test",
* label = @Translation("Test configuration for query"),
* controllers = {
......
......@@ -13,7 +13,7 @@
/**
* Defines the ConfigTest configuration entity.
*
* @EntityType(
* @ConfigEntityType(
* id = "config_test",
* label = @Translation("Test configuration"),
* controllers = {
......
......@@ -14,7 +14,7 @@
/**
* Defines the contact category entity.
*
* @EntityType(
* @ConfigEntityType(
* id = "contact_category",
* label = @Translation("Contact category"),
* controllers = {
......
......@@ -14,7 +14,7 @@
/**
* Defines the contact message entity.
*
* @EntityType(
* @ContentEntityType(
* id = "contact_message",
* label = @Translation("Contact message"),
* controllers = {
......
......@@ -13,12 +13,9 @@
/**
* Defines the configured text editor entity.
*
* @EntityType(
* @ConfigEntityType(
* id = "editor",
* label = @Translation("Editor"),
* controllers = {
* "storage" = "Drupal\Core\Config\Entity\ConfigStorageController"
* },
* config_prefix = "editor.editor",
* entity_keys = {
* "id" = "format",
......
......@@ -14,12 +14,9 @@
* Configuration entity that contains widget options for all components of a
* entity form in a given form mode.
*
* @EntityType(
* @ConfigEntityType(
* id = "entity_form_display",
* label = @Translation("Entity form display"),
* controllers = {
* "storage" = "Drupal\Core\Config\Entity\ConfigStorageController"
* },
* config_prefix = "entity.form_display",
* entity_keys = {
* "id" = "id",
......
......@@ -27,17 +27,17 @@
* @see entity_get_form_modes()
* @see hook_entity_form_mode_info_alter()
*
* @EntityType(
* @ConfigEntityType(
* id = "form_mode",
* label = @Translation("Form mode"),
* controllers = {
* "storage" = "Drupal\entity\EntityDisplayModeStorageController",
* "list" = "Drupal\entity\EntityFormModeListController",
* "form" = {
* "add" = "Drupal\entity\Form\EntityFormModeAddForm",
* "edit" = "Drupal\entity\Form\EntityDisplayModeEditForm",
* "delete" = "Drupal\entity\Form\EntityDisplayModeDeleteForm"
* },
* "storage" = "Drupal\entity\EntityDisplayModeStorageController"
* }
* },
* admin_permission = "administer display modes",
* config_prefix = "entity.form_mode",
......
......@@ -16,7 +16,7 @@
* Configuration entity that contains display options for all components of a
* rendered entity in a given view mode.
*
* @EntityType(
* @ConfigEntityType(
* id = "entity_view_display",
* label = @Translation("Entity view display"),
* controllers = {
......
......@@ -28,7 +28,7 @@
* @see entity_get_view_modes()
* @see hook_entity_view_mode_info_alter()
*
* @EntityType(
* @ConfigEntityType(
* id = "view_mode",
* label = @Translation("View mode"),
* controllers = {
......@@ -37,8 +37,7 @@
* "add" = "Drupal\entity\Form\EntityDisplayModeAddForm",
* "edit" = "Drupal\entity\Form\EntityDisplayModeEditForm",
* "delete" = "Drupal\entity\Form\EntityDisplayModeDeleteForm"
* },
* "storage" = "Drupal\entity\EntityDisplayModeStorageController"
* }
* },
* admin_permission = "administer display modes",
* config_prefix = "entity.view_mode",
......
......@@ -21,7 +21,7 @@
* @todo use 'field' as the id once hook_field_load() and friends
* are removed.
*
* @EntityType(
* @ConfigEntityType(
* id = "field_entity",
* label = @Translation("Field"),
* controllers = {
......
......@@ -17,7 +17,7 @@
/**
* Defines the Field instance entity.
*
* @EntityType(
* @ConfigEntityType(
* id = "field_instance",
* label = @Translation("Field instance"),
* controllers = {
......
......@@ -17,7 +17,7 @@
/**
* Defines the file entity class.
*
* @EntityType(
* @ContentEntityType(
* id = "file",
* label = @Translation("File"),
* controllers = {
......
......@@ -17,7 +17,7 @@
/**
* Represents a text format.
*
* @EntityType(
* @ConfigEntityType(
* id = "filter_format",
* label = @Translation("Text format"),
* controllers = {
......@@ -28,7 +28,6 @@
* },
* "list" = "Drupal\filter\FilterFormatListController",
* "access" = "Drupal\filter\FilterFormatAccessController",
* "storage" = "Drupal\Core\Config\Entity\ConfigStorageController"
* },
* config_prefix = "filter.format",
* admin_permission = "administer filters",
......
......@@ -19,7 +19,7 @@
/**
* Defines an image style configuration entity.
*
* @EntityType(
* @ConfigEntityType(
* id = "image_style",
* label = @Translation("Image style"),
* controllers = {
......@@ -29,7 +29,6 @@
* "delete" = "Drupal\image\Form\ImageStyleDeleteForm",
* "flush" = "Drupal\image\Form\ImageStyleFlushForm"
* },
* "storage" = "Drupal\Core\Config\Entity\ConfigStorageController",
* "list" = "Drupal\image\ImageStyleListController",
* },
* admin_permission = "administer image styles",
......
......@@ -15,11 +15,10 @@
/**
* Defines the Language entity.
*
* @EntityType(
* @ConfigEntityType(
* id = "language_entity",
* label = @Translation("Language"),
* controllers = {
* "storage" = "Drupal\Core\Config\Entity\ConfigStorageController",
* "list" = "Drupal\language\LanguageListController",
* "access" = "Drupal\language\LanguageAccessController",
* "form" = {
......
......@@ -17,14 +17,12 @@
* The migration entity stores the information about a single migration, like
* the source, process and destination plugins.
*
* @EntityType(
* @ConfigEntityType(
* id = "migration",
* label = @Translation("Migration"),
* module = "migrate",
* controllers = {
* "storage" = "Drupal\Core\Config\Entity\ConfigStorageController",
* "list" = "Drupal\Core\Config\Entity\DraggableListController",
* "access" = "Drupal\Core\Entity\EntityAccessController",
* "form" = {
* "add" = "Drupal\Core\Entity\EntityFormController",
* "edit" = "Drupal\Core\Entity\EntityFormController",
......
......@@ -18,12 +18,11 @@
/**
* Defines the node entity class.
*
* @EntityType(
* @ContentEntityType(
* id = "node",
* label = @Translation("Content"),
* bundle_label = @Translation("Content type"),
* controllers = {
* "storage" = "Drupal\Core\Entity\FieldableDatabaseStorageController",
* "view_builder" = "Drupal\node\NodeViewBuilder",
* "access" = "Drupal\node\NodeAccessController",
* "form" = {
......
......@@ -16,11 +16,10 @@
/**
* Defines the Node type configuration entity.
*
* @EntityType(
* @ConfigEntityType(
* id = "node_type",
* label = @Translation("Content type"),
* controllers = {
* "storage" = "Drupal\Core\Config\Entity\ConfigStorageController",
* "access" = "Drupal\node\NodeTypeAccessController",
* "form" = {
* "add" = "Drupal\node\NodeTypeFormController",
......
......@@ -13,11 +13,10 @@
/**
* Defines the Picture entity.
*
* @EntityType(
* @ConfigEntityType(
* id = "picture_mapping",
* label = @Translation("Picture mapping"),
* controllers = {
* "storage" = "Drupal\Core\Config\Entity\ConfigStorageController",
* "list" = "Drupal\picture\PictureMappingListController",
* "form" = {
* "edit" = "Drupal\picture\PictureMappingFormController",
......
......@@ -14,12 +14,9 @@
/**
* Config entity for working with RDF mappings.
*
* @EntityType(
* @ConfigEntityType(
* id = "rdf_mapping",
* label = @Translation("RDF mapping"),
* controllers = {
* "storage" = "Drupal\Core\Config\Entity\ConfigStorageController"
* },
* config_prefix = "rdf.mapping",
* entity_keys = {
* "id" = "id",
......
......@@ -17,7 +17,7 @@
/**
* Defines a configured search page.
*
* @EntityType(
* @ConfigEntityType(
* id = "search_page",
* label = @Translation("Search page"),
* controllers = {
......
......@@ -17,12 +17,11 @@
/**
* Defines the shortcut entity class.
*
* @EntityType(
* @ContentEntityType(
* id = "shortcut",
* label = @Translation("Shortcut link"),
* module = "shortcut",
* controllers = {
* "storage" = "Drupal\Core\Entity\FieldableDatabaseStorageController",
* "access" = "Drupal\shortcut\ShortcutAccessController",
* "form" = {
* "default" = "Drupal\shortcut\ShortcutFormController",
......
......@@ -15,7 +15,7 @@
/**
* Defines the Shortcut configuration entity.
*
* @EntityType(
* @ConfigEntityType(
* id = "shortcut_set",
* label = @Translation("Shortcut set"),
* controllers = {
......
......@@ -16,12 +16,9 @@
/**
* Defines the configured action entity.
*
* @EntityType(
* @ConfigEntityType(
* id = "action",
* label = @Translation("Action"),
* controllers = {
* "storage" = "Drupal\Core\Config\Entity\ConfigStorageController",
* },
* admin_permission = "administer actions",
* config_prefix = "system.action",
* entity_keys = {
......
......@@ -15,11 +15,10 @@
/**
* Defines the Date Format configuration entity class.
*
* @EntityType(
* @ConfigEntityType(
* id = "date_format",
* label = @Translation("Date format"),
* controllers = {
* "storage" = "Drupal\Core\Config\Entity\ConfigStorageController",
* "access" = "Drupal\system\DateFormatAccessController",
* "list" = "Drupal\system\DateFormatListController",
* "form" = {
......
......@@ -15,11 +15,10 @@
/**
* Defines the Menu configuration entity class.
*
* @EntityType(
* @ConfigEntityType(
* id = "menu",
* label = @Translation("Menu"),
* controllers = {
* "storage" = "Drupal\Core\Config\Entity\ConfigStorageController",
* "access" = "Drupal\system\MenuAccessController"
* },
* config_prefix = "system.menu",
......
......@@ -3234,7 +3234,7 @@ function hook_link_alter(&$variables) {
* To annotate a class as a plugin, add code similar to the following to the
* end of the documentation block immediately preceding the class declaration:
* @code
* * @EntityType(
* * @ContentEntityType(
* * id = "comment",
* * label = @Translation("Comment"),
* * ...
......
......@@ -17,11 +17,10 @@
/**
* Defines the test entity class.
*
* @EntityType(
* @ContentEntityType(
* id = "entity_test",
* label = @Translation("Test entity"),
* controllers = {
* "storage" = "Drupal\Core\Entity\FieldableDatabaseStorageController",
* "list" = "Drupal\entity_test\EntityTestListController",
* "view_builder" = "Drupal\entity_test\EntityTestViewBuilder",
* "access" = "Drupal\entity_test\EntityTestAccessController",
......
......@@ -12,11 +12,10 @@
/**
* Defines a test entity class for base fields display.
*
* @EntityType(
* @ContentEntityType(
* id = "entity_test_base_field_display",
* label = @Translation("Test entity - base field display"),
* controllers = {
* "storage" = "Drupal\Core\Entity\FieldableDatabaseStorageController",
* "access" = "Drupal\entity_test\EntityTestAccessController",
* "form" = {
* "default" = "Drupal\entity_test\EntityTestFormController"
......
......@@ -12,11 +12,10 @@
/**
* Defines the test entity class.
*
* @EntityType(
* @ContentEntityType(
* id = "entity_test_cache",
* label = @Translation("Test entity with field cache"),
* controllers = {
* "storage" = "Drupal\Core\Entity\FieldableDatabaseStorageController",
* "access" = "Drupal\entity_test\EntityTestAccessController",
* "form" = {
* "default" = "Drupal\entity_test\EntityTestFormController"
......
......@@ -10,12 +10,9 @@
/**
* Defines a test entity class with no access controller.
*
* @EntityType(
* @ContentEntityType(
* id = "entity_test_default_access",
* label = @Translation("Test entity with default access"),
* controllers = {
* "storage" = "Drupal\Core\Entity\FieldableDatabaseStorageController"
* },
* base_table = "entity_test",
* entity_keys = {
* "id" = "id",
......
......@@ -10,11 +10,10 @@
/**
* Test entity class.
*
* @EntityType(
* @ContentEntityType(
* id = "entity_test_label",
* label = @Translation("Entity Test label"),
* controllers = {
* "storage" = "Drupal\Core\Entity\FieldableDatabaseStorageController",
* "view_builder" = "Drupal\entity_test\EntityTestViewBuilder"
* },
* base_table = "entity_test",
......
......@@ -10,12 +10,9 @@
/**
* Test entity class.
*
* @EntityType(
* @ContentEntityType(
* id = "entity_test_label_callback",
* label = @Translation("Entity test label callback"),
* controllers = {
* "storage" = "Drupal\Core\Entity\FieldableDatabaseStorageController"
* },