PanelizerDefaultsDisplayAccess.php in Panelizer 8.3
File
src/Access/PanelizerDefaultsDisplayAccess.php
View source
<?php
namespace Drupal\panelizer\Access;
use Drupal\Core\Access\AccessResult;
class PanelizerDefaultsDisplayAccess {
public function isNotDefaultDisplay($machine_name) {
list($entity_type, $bundle, $view_mode, $default) = explode('__', $machine_name);
$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}",
]);
}
}