public function PanelizerEntityDefault::get_available_view_modes in Panelizer 7.3
Identify the view modes that are available for use with this entity bundle.
Parameters
string $bundle: The entity bundle to identify. Defaults to '0', a placeholder for all bundles on this entity.
Return value
array A list of view modes that are available to be panelized.
Overrides PanelizerEntityInterface::get_available_view_modes
3 calls to PanelizerEntityDefault::get_available_view_modes()
- PanelizerEntityDefault::add_bundle_setting_form in plugins/
entity/ PanelizerEntityDefault.class.php - Add the panelizer settings form to a single entity bundle config form.
- PanelizerEntityDefault::get_enabled_view_modes in plugins/
entity/ PanelizerEntityDefault.class.php - Identify the view modes that are enabled for use with Panelizer.
- PanelizerEntityDefault::settings_form in plugins/
entity/ PanelizerEntityDefault.class.php - Add entity specific form to the Panelizer settings form.
File
- plugins/
entity/ PanelizerEntityDefault.class.php, line 721 - Base class for the Panelizer Entity plugin.
Class
- PanelizerEntityDefault
- Base class for the Panelizer Entity plugin.
Code
public function get_available_view_modes($bundle = 0) {
if (!isset($this->enabled_view_modes[$bundle])) {
$view_modes = array();
$entity_info = entity_get_info($this->entity_type);
$bundle_info = array();
$view_mode_settings = array();
if (!empty($bundle)) {
$view_mode_settings = field_view_mode_settings($this->entity_type, $bundle);
if (isset($entity_info['bundles'][$bundle])) {
$bundle_info = $entity_info['bundles'][$bundle];
}
}
foreach ($this->plugin['view modes'] as $view_mode => $view_mode_info) {
// Automatically allow view modes that are part of Panels.
if (isset($entity_info['view modes'][$view_mode])) {
// Skip this view mode if it isn't enabled for this bundle.
if (!empty($bundle)) {
if (empty($view_mode_settings[$view_mode]['custom_settings'])) {
continue;
}
}
else {
if (isset($entity_info['view modes'][$view_mode]['custom settings']) && empty($entity_info['view modes'][$view_mode]['custom settings'])) {
continue;
}
}
}
$this->enabled_view_modes[$bundle][$view_mode] = $view_mode_info['label'];
}
// If no enabled view modes were found, set an empty entry so future
// calls of this function can be skipped.
if (!isset($this->enabled_view_modes[$bundle])) {
$this->enabled_view_modes[$bundle] = array();
}
}
return $this->enabled_view_modes[$bundle];
}