function _ds_entity_info_alter in Display Suite 7.2
Same name and namespace in other branches
- 7 ds.registry.inc \_ds_entity_info_alter()
Implements hook_entity_info_alter().
1 call to _ds_entity_info_alter()
- ds_entity_info_alter in ./
ds.module - Implements hook_entity_info_alter().
File
- includes/
ds.registry.inc, line 297 - Registry file for Display Suite.
Code
function _ds_entity_info_alter(&$entity_info) {
// Make sure ds_view_modes table exists.
if (!db_table_exists('ds_view_modes')) {
return;
}
ctools_include('export');
// Add custom view modes to entities.
$custom_view_modes = ctools_export_crud_load_all('ds_view_modes');
foreach ($custom_view_modes as $view_mode_key => $view_mode_value) {
$view_mode = array(
'label' => check_plain($view_mode_value->label),
'custom settings' => FALSE,
);
foreach ($view_mode_value->entities as $entity_type) {
if (isset($entity_info[$entity_type])) {
$entity_info[$entity_type]['view modes'][$view_mode_key] = $view_mode;
}
}
}
// Add layout if applicable.
$ds_layouts = ds_get_layout_info();
$ds_layout_settings = ctools_export_crud_load_all('ds_layout_settings');
foreach ($ds_layout_settings as $row) {
// Don't store any configuration if the layout is disabled.
if (!empty($row->disabled)) {
continue;
}
// Don't store any configuration with layouts that don't exist anymore.
if (!isset($ds_layouts[$row->layout])) {
continue;
}
// Don't store any configuration if the entity type is not defined.
if (!isset($entity_info[$row->entity_type])) {
continue;
}
// Don't store any configuration if the bundle doesn't exist.
if (!isset($entity_info[$row->entity_type]['bundles'][$row->bundle])) {
continue;
}
$layout = $ds_layouts[$row->layout];
$layout['layout'] = $row->layout;
$layout['settings'] = $row->settings;
$entity_info[$row->entity_type]['bundles'][$row->bundle]['layouts'][$row->view_mode] = $layout;
}
$revision = array(
'label' => 'Revision',
'custom settings' => FALSE,
);
$entity_info['node']['view modes']['revision'] = $revision;
}