function panelizer_entity_plugin_process in Panelizer 7.3
Same name and namespace in other branches
- 7.2 panelizer.module \panelizer_entity_plugin_process()
CTools process callback for an entity plugin.
This adds configuration data to the plugin so that we know what bundles it is enabled for.
1 call to panelizer_entity_plugin_process()
- PanelizerTestHelper::togglePanelizer in tests/
panelizer.helper.test - Helper function to quickly enable or disable Panelizer for an entity type.
1 string reference to 'panelizer_entity_plugin_process'
- panelizer_ctools_plugin_type in ./
panelizer.module - Implements hook_ctools_plugin_type().
File
- ./
panelizer.module, line 637 - The Panelizer module attaches panels to entities, providing default panels and allowing each panel to be configured independently by privileged users.
Code
function panelizer_entity_plugin_process(&$plugin, $info) {
$entity_type = $plugin['name'];
$entity_info = entity_get_info($entity_type);
$plugin['bundles'] = array();
if ($entity_info) {
foreach ($entity_info['bundles'] as $bundle => $label) {
if ($settings = variable_get('panelizer_defaults_' . $entity_type . '_' . $bundle, array())) {
// Translate from settings that existed prior to view mode support.
if (empty($settings['view modes'])) {
$old_settings = $settings;
$settings = array(
'view modes' => array(),
);
if (empty($plugin['uses page manager'])) {
$settings['view modes']['default'] = $old_settings;
}
else {
$settings['view modes']['page_manager'] = $old_settings;
}
$settings['status'] = $old_settings['status'];
}
$plugin['bundles'][$bundle] = $settings;
// Build the custom settings of the view modes for this bundle.
$view_mode_settings = field_view_mode_settings($entity_type, $bundle);
foreach ($entity_info['view modes'] as $view_mode_name => $view_mode_info) {
$plugin['view mode status'][$bundle][$view_mode_name] = !empty($view_mode_settings[$view_mode_name]['custom_settings']);
}
}
}
// Add our fake view modes.
$plugin['view modes'] = array(
'page_manager' => array(
'label' => t('Full page override'),
),
'default' => array(
'label' => t('Default'),
),
);
if (!empty($entity_info['view modes'])) {
foreach ($entity_info['view modes'] as $view_mode => $view_mode_info) {
$plugin['view modes'][$view_mode] = $view_mode_info;
}
}
// It seems silly to unset this after but the logic is cleaner to read.
if (empty($plugin['uses page manager'])) {
unset($plugin['view modes']['page_manager']);
}
}
drupal_alter('panelizer_entity_plugin_process', $plugin, $info);
}