Commit 7ab517f9 authored by webchick's avatar webchick

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

parent b3ce6ea2
......@@ -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 @@ public function getPermissionGranularity() {
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}
*/
......
......@@ -369,29 +369,6 @@ public function getAdminPermission();
*/
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.
*
......
......@@ -49,9 +49,6 @@
* "label" = "info",
* "uuid" = "uuid"
* },
* bundle_keys = {
* "bundle" = "type"
* },
* bundle_entity_type = "custom_block_type"
* )
*/
......
......@@ -43,9 +43,6 @@
* "label" = "subject",
* "uuid" = "uuid"
* },
* bundle_keys = {
* "bundle" = "field_id"
* },
* links = {
* "canonical" = "comment.permalink",
* "edit-form" = "comment.edit_page",
......
......@@ -152,7 +152,7 @@ public function buildHeader() {
*/
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;
}
......
......@@ -29,9 +29,6 @@
* },
* bundle_entity_type = "contact_category",
* fieldable = TRUE,
* bundle_keys = {
* "bundle" = "id"
* },
* links = {
* "admin-form" = "contact.category_edit"
* }
......
......@@ -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().
*/
......
......@@ -37,9 +37,6 @@
* "uuid" = "uuid",
* "bundle" = "bundle"
* },
* bundle_keys = {
* "bundle" = "bundle"
* }
* )
*/
class MenuLink extends Entity implements \ArrayAccess, MenuLinkInterface {
......
......@@ -48,9 +48,6 @@
* "label" = "title",
* "uuid" = "uuid"
* },
* bundle_keys = {
* "bundle" = "type"
* },
* bundle_entity_type = "node_type",
* permission_granularity = "bundle",
* links = {
......
......@@ -41,9 +41,6 @@
* "label" = "name",
* "uuid" = "uuid"
* },
* bundle_keys = {
* "bundle" = "vid"
* },
* bundle_entity_type = "taxonomy_vocabulary",
* links = {
* "canonical" = "taxonomy.term_page",
......
......@@ -563,7 +563,7 @@ protected function buildFilters(&$form, &$form_state) {
$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 @@ protected function defaultDisplayFiltersUser(array $form, array &$form_state) {
$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.
......
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