From 7ab517f9efd95f953ef698bf9e661362a7bb0c71 Mon Sep 17 00:00:00 2001 From: webchick Date: Thu, 23 Jan 2014 23:28:50 -0800 Subject: [PATCH] Issue #2177971 by chr.fritsch, Berdir: Remove bundle_keys annotation and related methods. --- core/lib/Drupal/Core/Entity/EntityType.php | 28 ------------------- .../Core/Entity/EntityTypeInterface.php | 23 --------------- .../custom_block/Entity/CustomBlock.php | 3 -- .../lib/Drupal/comment/Entity/Comment.php | 3 -- ...TranslationFieldInstanceListController.php | 2 +- .../lib/Drupal/contact/Entity/Message.php | 3 -- core/modules/field/field.module | 23 --------------- .../lib/Drupal/menu_link/Entity/MenuLink.php | 3 -- .../node/lib/Drupal/node/Entity/Node.php | 3 -- .../lib/Drupal/taxonomy/Entity/Term.php | 3 -- .../Plugin/views/wizard/WizardPluginBase.php | 4 +-- 11 files changed, 3 insertions(+), 95 deletions(-) diff --git a/core/lib/Drupal/Core/Entity/EntityType.php b/core/lib/Drupal/Core/Entity/EntityType.php index 64e25d87680..b4fe29c3928 100644 --- a/core/lib/Drupal/Core/Entity/EntityType.php +++ b/core/lib/Drupal/Core/Entity/EntityType.php @@ -86,20 +86,6 @@ class EntityType implements EntityTypeInterface { */ protected $permission_granularity; - /** - * An array describing how the Field API can extract the information it needs - * from the bundle objects for this type (e.g Vocabulary objects for terms; - * not applicable for nodes): - * - bundle: The name of the property that contains the name of the bundle - * object. - * - * This entry can be omitted if this type's bundles do not exist as standalone - * objects. - * - * @var array - */ - protected $bundle_keys = array(); - /** * Indicates whether fields can be attached to entities of this type. * @@ -456,20 +442,6 @@ class EntityType implements EntityTypeInterface { return isset($this->permission_granularity) ? $this->permission_granularity : 'entity_type'; } - /** - * {@inheritdoc} - */ - public function getBundleKeys() { - return isset($this->bundle_keys) ? $this->bundle_keys : array(); - } - - /** - * {@inheritdoc} - */ - public function getBundleKey($name) { - return isset($this->bundle_keys[$name]) ? $this->bundle_keys[$name] : FALSE; - } - /** * {@inheritdoc} */ diff --git a/core/lib/Drupal/Core/Entity/EntityTypeInterface.php b/core/lib/Drupal/Core/Entity/EntityTypeInterface.php index f1da8c82da9..5d390be599c 100644 --- a/core/lib/Drupal/Core/Entity/EntityTypeInterface.php +++ b/core/lib/Drupal/Core/Entity/EntityTypeInterface.php @@ -369,29 +369,6 @@ interface EntityTypeInterface { */ public function getPermissionGranularity(); - /** - * Get all bundle keys defined on the annotation. - * - * @return array - * An array describing how the Field API can extract the information it - * needs from the bundle objects for this type (e.g Vocabulary objects for - * terms; not applicable for nodes): - * - bundle: The name of the property that contains the name of the bundle - * object. - */ - public function getBundleKeys(); - - /** - * Returns a single bundle key. - * - * @param string $name - * The name of the bundle key. - * - * @return string|bool - * The value of the bundle key. - */ - public function getBundleKey($name); - /** * Indicates whether fields can be attached to entities of this type. * diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/Entity/CustomBlock.php b/core/modules/block/custom_block/lib/Drupal/custom_block/Entity/CustomBlock.php index 4c900daaa6e..643fa335673 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/Entity/CustomBlock.php +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/Entity/CustomBlock.php @@ -49,9 +49,6 @@ use Drupal\custom_block\CustomBlockInterface; * "label" = "info", * "uuid" = "uuid" * }, - * bundle_keys = { - * "bundle" = "type" - * }, * bundle_entity_type = "custom_block_type" * ) */ diff --git a/core/modules/comment/lib/Drupal/comment/Entity/Comment.php b/core/modules/comment/lib/Drupal/comment/Entity/Comment.php index 3c8b696cc6e..6bcfd954dc1 100644 --- a/core/modules/comment/lib/Drupal/comment/Entity/Comment.php +++ b/core/modules/comment/lib/Drupal/comment/Entity/Comment.php @@ -43,9 +43,6 @@ use Drupal\Core\TypedData\DataDefinition; * "label" = "subject", * "uuid" = "uuid" * }, - * bundle_keys = { - * "bundle" = "field_id" - * }, * links = { * "canonical" = "comment.permalink", * "edit-form" = "comment.edit_page", diff --git a/core/modules/config_translation/lib/Drupal/config_translation/Controller/ConfigTranslationFieldInstanceListController.php b/core/modules/config_translation/lib/Drupal/config_translation/Controller/ConfigTranslationFieldInstanceListController.php index 736aee99b30..b708ded078e 100644 --- a/core/modules/config_translation/lib/Drupal/config_translation/Controller/ConfigTranslationFieldInstanceListController.php +++ b/core/modules/config_translation/lib/Drupal/config_translation/Controller/ConfigTranslationFieldInstanceListController.php @@ -152,7 +152,7 @@ class ConfigTranslationFieldInstanceListController extends ConfigTranslationEnti */ public function displayBundle() { // The bundle key is explicitly defined in the entity definition. - if ($this->baseEntityInfo->getBundleKey('bundle')) { + if ($this->baseEntityInfo->getKey('bundle')) { return TRUE; } diff --git a/core/modules/contact/lib/Drupal/contact/Entity/Message.php b/core/modules/contact/lib/Drupal/contact/Entity/Message.php index b8a1523c12d..573b3041c78 100644 --- a/core/modules/contact/lib/Drupal/contact/Entity/Message.php +++ b/core/modules/contact/lib/Drupal/contact/Entity/Message.php @@ -29,9 +29,6 @@ use Drupal\Core\Field\FieldDefinition; * }, * bundle_entity_type = "contact_category", * fieldable = TRUE, - * bundle_keys = { - * "bundle" = "id" - * }, * links = { * "admin-form" = "contact.category_edit" * } diff --git a/core/modules/field/field.module b/core/modules/field/field.module index 408d816656f..f7081e9c248 100644 --- a/core/modules/field/field.module +++ b/core/modules/field/field.module @@ -471,29 +471,6 @@ function field_view_field(ContentEntityInterface $entity, $field_name, $display_ return $output; } -/** - * Extracts the bundle name from a bundle object. - * - * @param $entity_type - * The type of $entity; e.g., 'node' or 'user'. - * @param $bundle - * The bundle object (or string if bundles for this entity type do not exist - * as standalone objects). - * - * @return - * The bundle name. - */ -function field_extract_bundle($entity_type, $bundle) { - if (is_string($bundle)) { - return $bundle; - } - - $info = \Drupal::entityManager()->getDefinition($entity_type); - if (is_object($bundle) && ($bundle_key = $info->getBundleKey('bundle')) && isset($bundle->{$bundle_key})) { - return $bundle->{$bundle_key}; - } -} - /** * Implements hook_page_build(). */ diff --git a/core/modules/menu_link/lib/Drupal/menu_link/Entity/MenuLink.php b/core/modules/menu_link/lib/Drupal/menu_link/Entity/MenuLink.php index e4672685b6c..36362c8b3a1 100644 --- a/core/modules/menu_link/lib/Drupal/menu_link/Entity/MenuLink.php +++ b/core/modules/menu_link/lib/Drupal/menu_link/Entity/MenuLink.php @@ -37,9 +37,6 @@ use Symfony\Component\Routing\Route; * "uuid" = "uuid", * "bundle" = "bundle" * }, - * bundle_keys = { - * "bundle" = "bundle" - * } * ) */ class MenuLink extends Entity implements \ArrayAccess, MenuLinkInterface { diff --git a/core/modules/node/lib/Drupal/node/Entity/Node.php b/core/modules/node/lib/Drupal/node/Entity/Node.php index 90d4fac4b9a..0d4683ec400 100644 --- a/core/modules/node/lib/Drupal/node/Entity/Node.php +++ b/core/modules/node/lib/Drupal/node/Entity/Node.php @@ -48,9 +48,6 @@ use Drupal\node\NodeInterface; * "label" = "title", * "uuid" = "uuid" * }, - * bundle_keys = { - * "bundle" = "type" - * }, * bundle_entity_type = "node_type", * permission_granularity = "bundle", * links = { diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Entity/Term.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Entity/Term.php index bf85ab86676..b28a6d918c7 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Entity/Term.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Entity/Term.php @@ -41,9 +41,6 @@ use Drupal\taxonomy\TermInterface; * "label" = "name", * "uuid" = "uuid" * }, - * bundle_keys = { - * "bundle" = "vid" - * }, * bundle_entity_type = "taxonomy_vocabulary", * links = { * "canonical" = "taxonomy.term_page", diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/wizard/WizardPluginBase.php b/core/modules/views/lib/Drupal/views/Plugin/views/wizard/WizardPluginBase.php index 8de866ca05f..32f6414bbe5 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/views/wizard/WizardPluginBase.php +++ b/core/modules/views/lib/Drupal/views/Plugin/views/wizard/WizardPluginBase.php @@ -563,7 +563,7 @@ abstract class WizardPluginBase extends PluginBase implements WizardInterface { $bundles = entity_get_bundles($this->entity_type); // If the current base table support bundles and has more than one (like user). - if (!empty($bundles) && $this->entity_info && $this->entity_info->getBundleKeys()) { + if (!empty($bundles) && $this->entity_info) { // Get all bundles and their human readable names. $options = array('all' => t('All')); foreach ($bundles as $type => $bundle) { @@ -837,7 +837,7 @@ abstract class WizardPluginBase extends PluginBase implements WizardInterface { $filters = array(); if (!empty($form_state['values']['show']['type']) && $form_state['values']['show']['type'] != 'all') { - $bundle_key = $this->entity_info->getBundleKey('bundle'); + $bundle_key = $this->entity_info->getKey('bundle'); // Figure out the table where $bundle_key lives. It may not be the same as // the base table for the view; the taxonomy vocabulary machine_name, for // example, is stored in taxonomy_vocabulary, not taxonomy_term_data.