You are here

class DefaultAccess in Panelizer 8.3

Same name and namespace in other branches
  1. 8.5 src/Access/DefaultAccess.php \Drupal\panelizer\Access\DefaultAccess
  2. 8.4 src/Access/DefaultAccess.php \Drupal\panelizer\Access\DefaultAccess

Hierarchy

Expanded class hierarchy of DefaultAccess

1 string reference to 'DefaultAccess'
panelizer.services.yml in ./panelizer.services.yml
panelizer.services.yml
1 service uses DefaultAccess
panelizer.default.access in ./panelizer.services.yml
Drupal\panelizer\Access\DefaultAccess

File

src/Access/DefaultAccess.php, line 12

Namespace

Drupal\panelizer\Access
View source
class DefaultAccess implements AccessInterface {

  /**
   * The Panelizer service.
   *
   * @var \Drupal\panelizer\PanelizerInterface
   */
  protected $panelizer;

  /**
   * DefaultAccess constructor.
   *
   * @param \Drupal\panelizer\PanelizerInterface $panelizer
   *   The Panelizer service.
   */
  public function __construct(PanelizerInterface $panelizer) {
    $this->panelizer = $panelizer;
  }

  /**
   * Determines access to a default Panelizer layout.
   *
   * @param string $entity_type_id
   *   The panelized entity type ID.
   * @param string $bundle
   *   The panelized bundle ID.
   * @param string $view_mode_name
   *   The panelized view mode ID.
   *
   * @return \Drupal\Core\Access\AccessResult
   */
  public function access($entity_type_id, $bundle, $view_mode_name) {
    $settings = $this->panelizer
      ->getPanelizerSettings($entity_type_id, $bundle, $view_mode_name);
    return $settings['enable'] ? AccessResult::allowed() : AccessResult::forbidden();
  }

}

Members

Namesort descending Modifiers Type Description Overrides
DefaultAccess::$panelizer protected property The Panelizer service.
DefaultAccess::access public function Determines access to a default Panelizer layout.
DefaultAccess::__construct public function DefaultAccess constructor.