public function PanelizerEntityDefault::hook_panelizer_defaults in Panelizer 7.3
Same name and namespace in other branches
- 7.2 plugins/entity/PanelizerEntityDefault.class.php \PanelizerEntityDefault::hook_panelizer_defaults()
Implements a delegated hook_panelizer_defaults().
This makes sure that all panelized entities configured to have a default actually have one.
File
- plugins/
entity/ PanelizerEntityDefault.class.php, line 2836 - Base class for the Panelizer Entity plugin.
Class
- PanelizerEntityDefault
- Base class for the Panelizer Entity plugin.
Code
public function hook_panelizer_defaults(&$panelizers) {
// For features integration, if they have modified a default and put
// it into the database, we do not want to show one as a default.
// Otherwise, features can't latch onto it.
$default_names =& drupal_static('panelizer_defaults_in_database', NULL);
if (!isset($default_names)) {
$default_names = drupal_map_assoc(db_query("SELECT name FROM {panelizer_defaults} WHERE name LIKE '%:default&'")
->fetchCol());
}
$entity_info = entity_get_info($this->entity_type);
foreach ($this->plugin['bundles'] as $bundle => $info) {
// Don't bother if there are no
if (empty($info['status'])) {
continue;
}
foreach ($this->plugin['view modes'] as $view_mode => $view_mode_info) {
if (!empty($info['view modes'][$view_mode]['status']) && !empty($info['view modes'][$view_mode]['default'])) {
$panelizer = $this
->get_internal_default_panelizer($bundle, $view_mode);
if (empty($default_names[$panelizer->name]) && !isset($panelizers[$panelizer->name])) {
$panelizers[$panelizer->name] = $panelizer;
}
}
}
}
}