function panelizer_requirements in Panelizer 7.3
Same name and namespace in other branches
- 8.5 panelizer.install \panelizer_requirements()
- 6 panelizer.install \panelizer_requirements()
- 7 panelizer.install \panelizer_requirements()
- 7.2 panelizer.install \panelizer_requirements()
Implements hook_requirements().
File
- ./
panelizer.install, line 234 - Install, update and uninstall functions for the panelizer module.
Code
function panelizer_requirements($phase) {
$return = array();
if ($phase === 'runtime') {
// Check for fields displaying on view modes through core config.
$view_modes_to_report = array();
foreach (entity_get_info() as $entity_type => $entity_info) {
if (isset($entity_info['view modes'])) {
$view_modes = array_keys($entity_info['view modes']);
// Add default to the list of view modes because that might be panelized
// too.
$view_modes[] = 'default';
if (!empty($entity_info['bundles'])) {
$bundles = $entity_info['bundles'];
}
else {
$bundles = array(
$entity_type => $entity_type,
);
}
foreach ($bundles as $bundle => $bundle_info) {
foreach ($view_modes as $view_mode) {
if (panelizer_view_mode_extra_field_displays($entity_type, $bundle, $view_mode)) {
$view_modes_to_report[] = array(
'entity_type' => $entity_type,
'bundle' => $bundle,
'view_mode' => $view_mode,
);
// @todo Should the display be updated to hide the fields?
// panelizer_hide_fields_on_panelized_view_mode($entity_type, $bundle, $view_mode);
}
}
}
}
}
if (!empty($view_modes_to_report)) {
$count = count($view_modes_to_report);
$return['double_display'] = array(
'title' => t('Panelizer'),
'value' => t('@number view mode / bundle / entity combination(s) use Panelizer but still have field displays configured.', array(
'@number' => $count,
)),
'description' => t('Panelizer replaces the normal entity display. Any view mode that use Panelizer should have all fields hidden through the normal display settings in order to avoid the overhead of generating the output twice.'),
'severity' => REQUIREMENT_WARNING,
);
$description_links = array();
foreach ($view_modes_to_report as $view_mode_array) {
extract($view_mode_array);
$handler = panelizer_entity_plugin_get_handler($entity_type);
$path = $handler
->admin_bundle_display_path($bundle, $view_mode);
$description_links[] = array(
'href' => $path,
'title' => implode(':', $view_mode_array),
);
}
$theme_variables = array(
'links' => $description_links,
'heading' => array(
'text' => 'Entity view modes that should have all fields hidden:',
'level' => 'h6',
),
);
$return['double_display']['description'] .= theme('links', $theme_variables);
}
}
return $return;
}