Issue #2177971 by chr.fritsch, Berdir: Remove bundle_keys annotation and related methods.

8.0.x
webchick 2014-01-23 23:28:50 -08:00
parent b3ce6ea2f4
commit 7ab517f9ef
11 changed files with 3 additions and 95 deletions

View File

@ -86,20 +86,6 @@ class EntityType implements EntityTypeInterface {
*/ */
protected $permission_granularity; 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. * 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'; 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} * {@inheritdoc}
*/ */

View File

@ -369,29 +369,6 @@ interface EntityTypeInterface {
*/ */
public function getPermissionGranularity(); 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. * Indicates whether fields can be attached to entities of this type.
* *

View File

@ -49,9 +49,6 @@ use Drupal\custom_block\CustomBlockInterface;
* "label" = "info", * "label" = "info",
* "uuid" = "uuid" * "uuid" = "uuid"
* }, * },
* bundle_keys = {
* "bundle" = "type"
* },
* bundle_entity_type = "custom_block_type" * bundle_entity_type = "custom_block_type"
* ) * )
*/ */

View File

@ -43,9 +43,6 @@ use Drupal\Core\TypedData\DataDefinition;
* "label" = "subject", * "label" = "subject",
* "uuid" = "uuid" * "uuid" = "uuid"
* }, * },
* bundle_keys = {
* "bundle" = "field_id"
* },
* links = { * links = {
* "canonical" = "comment.permalink", * "canonical" = "comment.permalink",
* "edit-form" = "comment.edit_page", * "edit-form" = "comment.edit_page",

View File

@ -152,7 +152,7 @@ class ConfigTranslationFieldInstanceListController extends ConfigTranslationEnti
*/ */
public function displayBundle() { public function displayBundle() {
// The bundle key is explicitly defined in the entity definition. // The bundle key is explicitly defined in the entity definition.
if ($this->baseEntityInfo->getBundleKey('bundle')) { if ($this->baseEntityInfo->getKey('bundle')) {
return TRUE; return TRUE;
} }

View File

@ -29,9 +29,6 @@ use Drupal\Core\Field\FieldDefinition;
* }, * },
* bundle_entity_type = "contact_category", * bundle_entity_type = "contact_category",
* fieldable = TRUE, * fieldable = TRUE,
* bundle_keys = {
* "bundle" = "id"
* },
* links = { * links = {
* "admin-form" = "contact.category_edit" * "admin-form" = "contact.category_edit"
* } * }

View File

@ -471,29 +471,6 @@ function field_view_field(ContentEntityInterface $entity, $field_name, $display_
return $output; 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(). * Implements hook_page_build().
*/ */

View File

@ -37,9 +37,6 @@ use Symfony\Component\Routing\Route;
* "uuid" = "uuid", * "uuid" = "uuid",
* "bundle" = "bundle" * "bundle" = "bundle"
* }, * },
* bundle_keys = {
* "bundle" = "bundle"
* }
* ) * )
*/ */
class MenuLink extends Entity implements \ArrayAccess, MenuLinkInterface { class MenuLink extends Entity implements \ArrayAccess, MenuLinkInterface {

View File

@ -48,9 +48,6 @@ use Drupal\node\NodeInterface;
* "label" = "title", * "label" = "title",
* "uuid" = "uuid" * "uuid" = "uuid"
* }, * },
* bundle_keys = {
* "bundle" = "type"
* },
* bundle_entity_type = "node_type", * bundle_entity_type = "node_type",
* permission_granularity = "bundle", * permission_granularity = "bundle",
* links = { * links = {

View File

@ -41,9 +41,6 @@ use Drupal\taxonomy\TermInterface;
* "label" = "name", * "label" = "name",
* "uuid" = "uuid" * "uuid" = "uuid"
* }, * },
* bundle_keys = {
* "bundle" = "vid"
* },
* bundle_entity_type = "taxonomy_vocabulary", * bundle_entity_type = "taxonomy_vocabulary",
* links = { * links = {
* "canonical" = "taxonomy.term_page", * "canonical" = "taxonomy.term_page",

View File

@ -563,7 +563,7 @@ abstract class WizardPluginBase extends PluginBase implements WizardInterface {
$bundles = entity_get_bundles($this->entity_type); $bundles = entity_get_bundles($this->entity_type);
// If the current base table support bundles and has more than one (like user). // 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. // Get all bundles and their human readable names.
$options = array('all' => t('All')); $options = array('all' => t('All'));
foreach ($bundles as $type => $bundle) { foreach ($bundles as $type => $bundle) {
@ -837,7 +837,7 @@ abstract class WizardPluginBase extends PluginBase implements WizardInterface {
$filters = array(); $filters = array();
if (!empty($form_state['values']['show']['type']) && $form_state['values']['show']['type'] != 'all') { 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 // 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 // the base table for the view; the taxonomy vocabulary machine_name, for
// example, is stored in taxonomy_vocabulary, not taxonomy_term_data. // example, is stored in taxonomy_vocabulary, not taxonomy_term_data.