class PanelizerDefaultsDisplayAccess in Panelizer 8.3
Same name and namespace in other branches
- 8.5 src/Access/PanelizerDefaultsDisplayAccess.php \Drupal\panelizer\Access\PanelizerDefaultsDisplayAccess
- 8.4 src/Access/PanelizerDefaultsDisplayAccess.php \Drupal\panelizer\Access\PanelizerDefaultsDisplayAccess
Provides a custom access checking mechanism for default displays.
Hierarchy
- class \Drupal\panelizer\Access\PanelizerDefaultsDisplayAccess
Expanded class hierarchy of PanelizerDefaultsDisplayAccess
File
- src/
Access/ PanelizerDefaultsDisplayAccess.php, line 10
Namespace
Drupal\panelizer\AccessView source
class PanelizerDefaultsDisplayAccess {
/**
* Custom access checker for determining the default display of the bundle.
*
* @param string $machine_name
* The machine name of the default display.
*
* @return \Drupal\Core\Access\AccessResult
*/
public function isNotDefaultDisplay($machine_name) {
list($entity_type, $bundle, $view_mode, $default) = explode('__', $machine_name);
/** @var \Drupal\panelizer\Panelizer $panelizer */
$panelizer = \Drupal::service('panelizer');
$settings = $panelizer
->getPanelizerSettings($entity_type, $bundle, $view_mode);
if ($settings['default'] != $default) {
$access = AccessResult::allowed();
}
else {
$access = AccessResult::forbidden();
}
return $access
->addCacheTags([
"panelizer_default:{$entity_type}:{$bundle}:{$view_mode}",
"panelizer_default:{$entity_type}:{$bundle}:{$view_mode}:{$default}",
]);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
PanelizerDefaultsDisplayAccess:: |
public | function | Custom access checker for determining the default display of the bundle. |