Commit b0da3ae6 authored by alexpott's avatar alexpott
Browse files

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",
......
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