Commit 2fa3ffe1 authored by Dries's avatar Dries

Issue #1822458 by tim.plunkett, effulgentsia: Move dynamic parts (view modes,...

Issue #1822458 by tim.plunkett, effulgentsia: Move dynamic parts (view modes, bundles) out of entity_info().
parent de63cbb8
......@@ -24,11 +24,114 @@
* @see entity_get_info()
*/
function hook_entity_info(&$entity_info) {
// Add the 'Print' view mode for nodes.
$entity_info['node']['view_modes']['print'] = array(
'label' => t('Print'),
'custom_settings' => FALSE,
// Add a form controller for a custom node form without overriding the default
// node form. To override the default node form, use hook_entity_info_alter()
// to alter $entity_info['node']['form_controller_class']['default'].
$entity_info['node']['form_controller_class']['mymodule_foo'] = 'Drupal\mymodule\NodeFooFormController';
}
/**
* Describe the view modes for entity types.
*
* View modes let entities be displayed differently depending on the context.
* For instance, a node can be displayed differently on its own page ('full'
* mode), on the home page or taxonomy listings ('teaser' mode), or in an RSS
* feed ('rss' mode). Modules taking part in the display of the entity (notably
* the Field API) can adjust their behavior depending on the requested view
* mode. An additional 'default' view mode is available for all entity types.
* This view mode is not intended for actual entity display, but holds default
* display settings. For each available view mode, administrators can configure
* whether it should use its own set of field display settings, or just
* replicate the settings of the 'default' view mode, thus reducing the amount
* of display configurations to keep track of.
*
* @return array
* An associative array of all entity view modes, keyed by the entity
* type name, and then the view mode name, with the following keys:
* - label: The human-readable name of the view mode.
* - custom_settings: A boolean specifying whether the view mode should by
* default use its own custom field display settings. If FALSE, entities
* displayed in this view mode will reuse the 'default' display settings
* by default (e.g. right after the module exposing the view mode is
* enabled), but administrators can later use the Field UI to apply custom
* display settings specific to the view mode.
*
* @see entity_get_view_modes()
* @see hook_entity_view_mode_info_alter()
*/
function hook_entity_view_mode_info() {
$view_modes['user']['full'] = array(
'label' => t('User account'),
);
$view_modes['user']['compact'] = array(
'label' => t('Compact'),
'custom_settings' => TRUE,
);
return $view_modes;
}
/**
* Alter the view modes for entity types.
*
* @param array $view_modes
* An array of view modes, keyed first by entity type, then by view mode name.
*
* @see entity_get_view_modes()
* @see hook_entity_view_mode_info()
*/
function hook_entity_view_mode_info_alter(&$view_modes) {
$view_modes['user']['full']['custom_settings'] = TRUE;
}
/**
* Describe the bundles for entity types.
*
* @return array
* An associative array of all entity bundles, keyed by the entity
* type name, and then the bundle name, with the following keys:
* - label: The human-readable name of the bundle.
* - uri_callback: The same as the 'uri_callback' key defined for the entity
* type in the EntityManager, but for the bundle only. When determining
* the URI of an entity, if a 'uri_callback' is defined for both the
* entity type and the bundle, the one for the bundle is used.
* - admin: An array of information that allows Field UI pages to attach
* themselves to the existing administration pages for the bundle.
* Elements:
* - path: the path of the bundle's main administration page, as defined
* in hook_menu(). If the path includes a placeholder for the bundle,
* the 'bundle argument', 'bundle helper' and 'real path' keys below
* are required.
* - bundle argument: The position of the placeholder in 'path', if any.
* - real path: The actual path (no placeholder) of the bundle's main
* administration page. This will be used to generate links.
* - access callback: As in hook_menu(). 'user_access' will be assumed if
* no value is provided.
* - access arguments: As in hook_menu().
*
* @see entity_get_bundles()
* @see hook_entity_bundle_info_alter()
*/
function hook_entity_bundle_info() {
$bundles['user']['user'] = array(
'label' => t('User'),
'admin' => array(
'path' => 'admin/config/people/accounts',
),
);
return $bundles;
}
/**
* Alter the bundles for entity types.
*
* @param array $bundles
* An array of bundles, keyed first by entity type, then by bundle name.
*
* @see entity_get_bundles()
* @see hook_entity_bundle_info()
*/
function hook_entity_bundle_info_alter(&$bundles) {
$bundles['user']['user']['label'] = t('Full account');
}
/**
......
......@@ -49,23 +49,91 @@ function entity_get_info($entity_type = NULL) {
*/
function entity_info_cache_clear() {
drupal_static_reset('entity_get_info');
drupal_static_reset('entity_get_view_modes');
drupal_static_reset('entity_get_bundles');
// Clear all languages.
cache()->deleteTags(array('entity_info' => TRUE));
}
/**
* Returns the defined bundles for the given entity type.
* Returns the entity bundle info.
*
* @param string $entity_type
* The entity type whose bundles should be returned.
* @param string|null $entity_type
* The entity type whose bundle info should be returned, or NULL for all
* bundles info. Defaults to NULL.
*
* @return array
* An array containing the bundle names or the entity type name itself if no
* bundle is defined.
* The bundle info for a specific entity type, or all entity types.
*/
function entity_get_bundles($entity_type) {
$entity_info = entity_get_info($entity_type);
return isset($entity_info['bundles']) ? array_keys($entity_info['bundles']) : array($entity_type);
function entity_get_bundles($entity_type = NULL) {
$bundles = &drupal_static(__FUNCTION__);
if (!$bundles) {
$langcode = language(LANGUAGE_TYPE_INTERFACE)->langcode;
if ($cache = cache()->get("entity_bundle_info:$langcode")) {
$bundles = $cache->data;
}
else {
$bundles = module_invoke_all('entity_bundle_info');
// If no bundles are provided, use the entity type name and label.
foreach (entity_get_info() as $type => $entity_info) {
if (!isset($bundles[$type])) {
$bundles[$type][$type]['label'] = $entity_info['label'];
}
}
drupal_alter('entity_bundle_info', $bundles);
cache()->set("entity_bundle_info:$langcode", $bundles, CacheBackendInterface::CACHE_PERMANENT, array('entity_info' => TRUE));
}
}
if (empty($entity_type)) {
return $bundles;
}
elseif (isset($bundles[$entity_type])) {
return $bundles[$entity_type];
}
return array();
}
/**
* Returns the entity view mode info.
*
* @param string|null $entity_type
* The entity type whose view mode info should be returned, or NULL for all
* view mode info. Defaults to NULL.
*
* @return array
* The view mode info for a specific entity type, or all entity types.
*/
function entity_get_view_modes($entity_type = NULL) {
$view_modes = &drupal_static(__FUNCTION__);
if (!$view_modes) {
$langcode = language(LANGUAGE_TYPE_INTERFACE)->langcode;
if ($cache = cache()->get("entity_view_mode_info:$langcode")) {
$view_modes = $cache->data;
}
else {
$view_modes = module_invoke_all('entity_view_mode_info');
foreach ($view_modes as $type => $entity_info) {
foreach ($entity_info as $view_mode => $view_mode_info) {
$view_modes[$type][$view_mode] += array(
'custom_settings' => FALSE,
);
}
}
drupal_alter('entity_view_mode_info', $view_modes);
cache()->set("entity_view_mode_info:$langcode", $view_modes, CacheBackendInterface::CACHE_PERMANENT, array('entity_info' => TRUE));
}
}
if (empty($entity_type)) {
return $view_modes;
}
elseif (isset($view_modes[$entity_type])) {
return $view_modes[$entity_type];
}
return array();
}
/**
......
......@@ -154,8 +154,9 @@ public function uri() {
// A bundle-specific callback takes precedence over the generic one for the
// entity type.
$entity_info = $this->entityInfo();
if (isset($entity_info['bundles'][$bundle]['uri_callback'])) {
$uri_callback = $entity_info['bundles'][$bundle]['uri_callback'];
$bundles = entity_get_bundles($this->entityType);
if (isset($bundles[$bundle]['uri_callback'])) {
$uri_callback = $bundles[$bundle]['uri_callback'];
}
elseif (isset($entity_info['uri_callback'])) {
$uri_callback = $entity_info['uri_callback'];
......
......@@ -109,49 +109,6 @@
* Elements:
* - bundle: The name of the property that contains the name of the bundle
* object.
* - bundles: An array describing all bundles for this object type. Keys are
* bundle machine names, as found in the objects' 'bundle' property
* (defined in the 'entity_keys' entry for the entity type in the
* EntityManager). Elements:
* - label: The human-readable name of the bundle.
* - uri_callback: The same as the 'uri_callback' key defined for the entity
* type in the EntityManager, but for the bundle only. When determining
* the URI of an entity, if a 'uri_callback' is defined for both the
* entity type and the bundle, the one for the bundle is used.
* - admin: An array of information that allows Field UI pages to attach
* themselves to the existing administration pages for the bundle.
* Elements:
* - path: the path of the bundle's main administration page, as defined
* in hook_menu(). If the path includes a placeholder for the bundle,
* the 'bundle argument', 'bundle helper' and 'real path' keys below
* are required.
* - bundle argument: The position of the placeholder in 'path', if any.
* - real path: The actual path (no placeholder) of the bundle's main
* administration page. This will be used to generate links.
* - access callback: As in hook_menu(). 'user_access' will be assumed if
* no value is provided.
* - access arguments: As in hook_menu().
* - view_modes: An array describing the view modes for the entity type. View
* modes let entities be displayed differently depending on the context.
* For instance, a node can be displayed differently on its own page
* ('full' mode), on the home page or taxonomy listings ('teaser' mode), or
* in an RSS feed ('rss' mode). Modules taking part in the display of the
* entity (notably the Field API) can adjust their behavior depending on
* the requested view mode. An additional 'default' view mode is available
* for all entity types. This view mode is not intended for actual entity
* display, but holds default display settings. For each available view
* mode, administrators can configure whether it should use its own set of
* field display settings, or just replicate the settings of the 'default'
* view mode, thus reducing the amount of display configurations to keep
* track of. Keys of the array are view mode names. Each view mode is
* described by an array with the following key/value pairs:
* - label: The human-readable name of the view mode.
* - custom_settings: A boolean specifying whether the view mode should by
* default use its own custom field display settings. If FALSE, entities
* displayed in this view mode will reuse the 'default' display settings
* by default (e.g. right after the module exposing the view mode is
* enabled), but administrators can later use the Field UI to apply custom
* display settings specific to the view mode.
* - menu_base_path: (optional) The base menu router path to which the entity
* administration user interface responds. It can be used to generate UI
* links and to attach additional router items to the entity UI in a generic
......@@ -229,8 +186,6 @@ class EntityManager extends PluginManagerBase {
'access_controller_class' => 'Drupal\Core\Entity\EntityAccessController',
'static_cache' => TRUE,
'translation' => array(),
'bundles' => array(),
'view_modes' => array(),
);
/**
......@@ -286,17 +241,6 @@ public function processDefinition(&$definition, $plugin_id) {
return;
}
foreach ($definition['view_modes'] as $view_mode => $view_mode_info) {
$definition['view_modes'][$view_mode] += array(
'custom_settings' => FALSE,
);
}
// If no bundle key is provided, assume a single bundle, named after
// the entity type.
if (empty($definition['entity_keys']['bundle']) && empty($definition['bundles'])) {
$definition['bundles'] = array($plugin_id => array('label' => $definition['label']));
}
// Prepare entity schema fields SQL info for
// Drupal\Core\Entity\DatabaseStorageControllerInterface::buildQuery().
if (isset($definition['base_table'])) {
......
......@@ -250,14 +250,14 @@ function book_admin_paths() {
}
/**
* Implements hook_entity_info().
* Implements hook_entity_view_mode_info().
*/
function book_entity_info(&$info) {
function book_entity_view_mode_info() {
// Add the 'Print' view mode for nodes.
$info['node']['view_modes']['print'] = array(
$view_modes['node']['print'] = array(
'label' => t('Print'),
'custom_settings' => FALSE,
);
return $view_modes;
}
/**
......
......@@ -99,11 +99,22 @@ function comment_help($path, $arg) {
}
/**
* Implements hook_entity_info().
* Implements hook_entity_view_mode_info().
*/
function comment_entity_info(&$info) {
function comment_entity_view_mode_info() {
$view_modes['comment']['full'] = array(
'label' => t('Full comment'),
);
return $view_modes;
}
/**
* Implements hook_entity_bundle_info().
*/
function comment_entity_bundle_info() {
$bundles = array();
foreach (node_type_get_names() as $type => $name) {
$info['comment']['bundles']['comment_node_' . $type] = array(
$bundles['comment']['comment_node_' . $type] = array(
'label' => t('@node_type comment', array('@node_type' => $name)),
// Provide the node type/bundle name for other modules, so it does not
// have to be extracted manually from the bundle name.
......@@ -121,6 +132,7 @@ function comment_entity_info(&$info) {
),
);
}
return $bundles;
}
/**
......@@ -289,7 +301,7 @@ function comment_menu_alter(&$items) {
$items['admin/content']['description'] = 'Administer content and comments.';
// Adjust the Field UI tabs on admin/structure/types/manage/[node-type].
// See comment_entity_info().
// See comment_entity_bundle_info().
$items['admin/structure/types/manage/%comment_node_type/comment/fields']['title'] = 'Comment fields';
$items['admin/structure/types/manage/%comment_node_type/comment/fields']['weight'] = 3;
$items['admin/structure/types/manage/%comment_node_type/comment/display']['title'] = 'Comment display';
......@@ -1389,7 +1401,7 @@ function comment_delete_multiple($cids) {
* (optional) An array of entity IDs. If omitted, all entities are loaded.
* @param bool $reset
* Whether to reset the internal static entity cache. Note that the static
* cache is disabled in comment_entity_info() by default.
* cache is disabled by default.
*
* @return array
* An array of comment objects, indexed by comment ID.
......@@ -1408,7 +1420,7 @@ function comment_load_multiple(array $cids = NULL, $reset = FALSE) {
* The ID of the comment to be loaded.
* @param bool $reset
* Whether to reset the internal static entity cache. Note that the static
* cache is disabled in comment_entity_info() by default.
* cache is disabled by default.
*
* @return
* The comment object.
......
......@@ -35,12 +35,6 @@
* "bundle" = "node_type",
* "label" = "subject",
* "uuid" = "uuid"
* },
* view_modes = {
* "full" = {
* "label" = "Full comment",
* "custom_settings" = FALSE
* }
* }
* )
*/
......
......@@ -77,12 +77,10 @@ function pre_render($result) {
* in views_plugin_row_comment|node_rss.inc
*/
function options_form_summary_options() {
$entity_info = entity_get_info('node');
$view_modes = entity_get_view_modes('node');
$options = array();
if (!empty($entity_info['view_modes'])) {
foreach ($entity_info['view_modes'] as $mode => $settings) {
$options[$mode] = $settings['label'];
}
foreach ($view_modes as $mode => $settings) {
$options[$mode] = $settings['label'];
}
$options['title'] = t('Title only');
$options['default'] = t('Use site default RSS settings');
......
......@@ -174,12 +174,13 @@ function _contact_personal_tab_access($account) {
}
/**
* Implements hook_entity_info().
* Implements hook_entity_bundle_info().
*/
function contact_entity_info(&$types) {
function contact_entity_bundle_info() {
$bundles = array();
foreach (config_get_storage_names_with_prefix('contact.category.') as $config_name) {
$config = config($config_name);
$types['contact_message']['bundles'][$config->get('id')] = array(
$bundles['contact_message'][$config->get('id')] = array(
'label' => $config->get('label'),
'admin' => array(
'path' => 'admin/structure/contact/manage/%contact_category',
......@@ -189,6 +190,7 @@ function contact_entity_info(&$types) {
),
);
}
return $bundles;
}
/**
......@@ -196,8 +198,7 @@ function contact_entity_info(&$types) {
*/
function contact_field_extra_fields() {
$fields = array();
$entity_info = entity_get_info('contact_message');
foreach (array_keys($entity_info['bundles']) as $bundle) {
foreach (array_keys(entity_get_bundles('contact_message')) as $bundle) {
$fields['contact_message'][$bundle]['form']['name'] = array(
'label' => t('Sender name'),
'description' => t('Text'),
......
......@@ -275,31 +275,6 @@ function field_info_storage_types($storage_type = NULL) {
}
}
/**
* Returns information about existing bundles.
*
* @param $entity_type
* The type of entity; e.g. 'node' or 'user'.
*
* @return
* An array of bundles for the $entity_type keyed by bundle name, or, if no
* $entity_type was provided, the array of all existing bundles, keyed by
* entity type.
*/
function field_info_bundles($entity_type = NULL) {
$info = entity_get_info();
if ($entity_type) {
return isset($info[$entity_type]['bundles']) ? $info[$entity_type]['bundles'] : array();
}
$bundles = array();
foreach ($info as $type => $entity_info) {
$bundles[$type] = $entity_info['bundles'];
}
return $bundles;
}
/**
* Returns all field definitions.
*
......
......@@ -746,8 +746,8 @@ function field_view_mode_settings($entity_type, $bundle) {
// Include view modes for which nothing has been stored yet, but whose
// definition in hook_entity_info_alter() specify they should use custom
// settings by default.
$entity_info = entity_get_info($entity_type);
foreach ($entity_info['view_modes'] as $view_mode => $view_mode_info) {
$view_modes = entity_get_view_modes($entity_type);
foreach ($view_modes as $view_mode => $view_mode_info) {
if (!isset($settings[$view_mode]['custom_settings']) && $view_mode_info['custom_settings']) {
$settings[$view_mode]['custom_settings'] = TRUE;
}
......
......@@ -19,8 +19,17 @@ function field_test_entity_info_alter(&$entity_info) {
// Disable the entity type translation handler.
foreach ($entity_info as $entity_type => $info) {
$entity_info[$entity_type]['translation'][$entity_type] = FALSE;
if ($info['module'] == 'field_test') {
$entity_info[$entity_type]['view_modes'] = array(
}
}
/**
* Implements hook_entity_view_mode_info_alter().
*/
function field_test_entity_view_mode_info_alter(&$view_modes) {
$entity_info = entity_get_info();
foreach ($entity_info as $entity_type => $info) {
if ($entity_info[$entity_type]['module'] == 'field_test') {
$view_modes[$entity_type] = array(
'full' => array(
'label' => t('Full object'),
'custom_settings' => TRUE,
......@@ -30,12 +39,23 @@ function field_test_entity_info_alter(&$entity_info) {
'custom_settings' => TRUE,
),
);
$entity_info[$entity_type]['bundles'] = state()->get('field_test_bundles') ?: array('test_bundle' => array('label' => 'Test Bundle'));
}
}
}
/**
* Implements hook_entity_bundle_info_alter().
*/
function field_test_entity_bundle_info_alter(&$bundles) {
$entity_info = entity_get_info();
foreach ($bundles as $entity_type => $info) {
if ($entity_info[$entity_type]['module'] == 'field_test') {
$bundles[$entity_type] = state()->get('field_test_bundles') ?: array('test_bundle' => array('label' => 'Test Bundle'));
if ($entity_type == 'test_entity_bundle') {
$entity_info[$entity_type]['bundles'] += array('test_entity_2' => array('label' => 'Test entity 2'));
$bundles[$entity_type] += array('test_entity_2' => array('label' => 'Test entity 2'));
}
if ($entity_type == 'test_entity_bundle_key') {
$entity_info[$entity_type]['bundles'] += array('bundle1' => array('label' => 'Bundle1'), 'bundle2' => array('label' => 'Bundle2'));
$bundles[$entity_type] += array('bundle1' => array('label' => 'Bundle1'), 'bundle2' => array('label' => 'Bundle2'));
}
}
}
......
......@@ -45,9 +45,8 @@ function field_test_permission() {
*/
function field_test_menu() {
$items = array();
$bundles = field_info_bundles('test_entity');
foreach ($bundles as $bundle_name => $bundle_info) {
foreach (entity_get_bundles('test_entity') as $bundle_name => $bundle_info) {
$items['test-entity/add/' . $bundle_name] = array(
'title' => t('Add %bundle test_entity', array('%bundle' => $bundle_info['label'])),
'page callback' => 'field_test_entity_add',
......@@ -309,7 +308,7 @@ function field_test_field_extra_fields_alter(&$info) {
* @todo Remove when http://drupal.org/node/1822458 is fixed.
*/
function field_test_module_implements_alter(&$implementations, $hook) {
if ($hook == 'entity_info_alter' && isset($implementations['field_test']) && isset($implementations['rdf'])) {
if ($hook == 'entity_bundle_info_alter' && isset($implementations['field_test']) && isset($implementations['rdf'])) {
foreach (array('field_test', 'rdf') as $module) {
$group = $implementations[$module];
unset($implementations[$module]);
......
......@@ -174,8 +174,7 @@ function addField($field, $type, $langcode) {
// If there are bundles, pick one. It does not matter which,
// properties exist on all bundles.
if (!empty($entity_info['entity keys']['bundle'])) {
$bundles = array_keys($entity_info['bundles']);
$values[$entity_info['entity keys']['bundle']] = reset($bundles);
$values[$entity_info['entity keys']['bundle']] = key(entity_get_bundles('node'));
}
$entity = entity_create($entity_type, $values);
$propertyDefinitions = $entity->$specifier->getPropertyDefinitions();
......
......@@ -17,7 +17,7 @@
function field_ui_fields_list() {
$instances = field_info_instances();
$field_types = field_info_field_types();
$bundles = field_info_bundles();
$bundles = entity_get_bundles();
$modules = system_rebuild_module_data();
......@@ -654,7 +654,7 @@ function field_ui_widget_type_form($form, &$form_state, FieldInstance $instance)
$field_name = $instance['field_name'];
$field = field_info_field($field_name);
$bundles = field_info_bundles();
$bundles = entity_get_bundles();
$bundle_label = $bundles[$entity_type][$bundle]['label'];
$form = array(
......@@ -759,7 +759,7 @@ function field_ui_field_delete_form_submit($form, &$form_state) {
$field = field_info_field($field_name);
$instance = field_info_instance($entity_type, $field_name, $bundle);
$bundles = field_info_bundles();
$bundles = entity_get_bundles();
$bundle_label = $bundles[$entity_type][$bundle]['label'];
if (!empty($bundle) && $field && !$field['locked'] && $form_values['confirm']) {
......@@ -795,7 +795,7 @@ function field_ui_field_edit_form($form, &$form_state, $instance) {
$bundle = $instance['bundle'];
$entity_type = $instance['entity_type'];
$field = field_info_field($instance['field_name']);
$bundles = field_info_bundles();
$bundles = entity_get_bundles();
drupal_set_title(t('%instance settings for %bundle', array(
'%instance' => $instance['label'],
......
......@@ -71,7 +71,7 @@ function field_ui_menu() {
// Create tabs for all possible bundles.
foreach (entity_get_info() as $entity_type => $entity_info) {
if ($entity_info['fieldable']) {
foreach ($entity_info['bundles'] as $bundle_name => $bundle_info) {
foreach (entity_get_bundles($entity_type) as $bundle_name => $bundle_info) {
if (isset($bundle_info['admin'])) {
// Extract path information from the bundle.
$path = $bundle_info['admin']['path'];
......@@ -173,7 +173,7 @@ function field_ui_menu() {
// view modes, and use an access callback to determine which ones are
// actually visible for a given bundle.
$weight = 0;
$view_modes = array('default' => array('label' => t('Default'))) + $entity_info['view_modes'];
$view_modes = array('default' => array('label' => t('Default'))) + entity_get_view_modes($entity_type);
foreach ($view_modes as $view_mode => $view_mode_info) {
$items["$path/display/$view_mode"] = array(
'title' => $view_mode_info['label'],
......@@ -328,7 +328,7 @@ function field_ui_field_attach_create_bundle($entity_type, $bundle) {
* Determines the adminstration path for a bundle.
*/
function field_ui_bundle_admin_path($entity_type, $bundle_name) {
$bundles = field_info_bundles($entity_type);
$bundles = entity_get_bundles($entity_type);
$bundle_info = $bundles[$bundle_name];
if (isset($bundle_info['admin'])) {
return isset($bundle_info['admin']['real path']) ? $bundle_info['admin']['real path'] : $bundle_info['admin']['path'];
......
......@@ -346,8 +346,7 @@ public function form(array $form, array &$form_state) {
// Custom display settings.
if ($this->view_mode == 'default') {
$entity_info = entity_get_info($this->entity_type);
$view_modes = $entity_info['view_modes'];
$view_modes = entity_get_view_modes($this->entity_type);
// Only show the settings if there is more than one view mode.
if (count($view_modes) > 1) {
$form['modes'] = array(
......@@ -478,6 +477,7 @@ public function submit(array $form, array &$form_state) {
// Handle the 'view modes' checkboxes if present.
if ($this->view_mode == 'default' && !empty($form_values['view_modes_custom'])) {
$entity_info = entity_get_info($this->entity_type);
$view_modes = entity_get_view_modes($this->entity_type);
$bundle_settings = field_bundle_settings($this->entity_type, $this->bundle);
$view_mode_settings = field_view_mode_settings($this->entity_type, $this->bundle);
......@@ -491,7 +491,7 @@ public function submit(array $form, array &$form_state) {
$display->save();
}
$view_mode_label = $entity_info['view_modes'][$view_mode]['label'];
$view_mode_label = $view_modes[$view_mode]['label'];
$path = field_ui_bundle_admin_path($this->entity_type, $this->bundle) . "/display/$view_mode";
drupal_set_message(t('The %view_mode mode now uses custom display settings. You might want to <a href="@url">configure them</a>.', array('%view_mode' => $view_mode_label, '@url' => url($path))));
}
......
......@@ -89,6 +89,16 @@ function file_element_info() {
return $types;
}
/**
* Implements hook_entity_view_mode_info().
*/
function file_entity_view_mode_info() {
$view_modes['file']['full'] = array(
'label' => t('File default'),
);
return $view_modes;
}
/**
* Loads file entities from the database.
*
......
......@@ -26,12 +26,6 @@
* "id" = "fid",
* "label" = "filename",
* "uuid" = "uuid"
* },
* view_modes = {
* "full" = {
* "label" = "File default",
* "custom_settings" = FALSE
* }
* }
* )
*/
......
......@@ -217,13 +217,13 @@ function forum_menu_local_tasks_alter(&$data, $router_item, $root_path) {
}
/**
* Implements hook_entity_info_alter().
* Implements hook_entity_bundle_info_alter().
*/
function forum_entity_info_alter(&$info) {
function forum_entity_bundle_info_alter(&$bundles) {
// Take over URI construction for taxonomy terms that are forums.