1 entity_bundle_layout_access.inc EntityBundleLayoutAccess::checkAccess()

Checks for access based on the available context.

Return value

boolean: The result of the access check.

Overrides LayoutAccess::checkAccess

File

core/modules/layout/plugins/access/entity_bundle_layout_access.inc, line 76
Plugin to provide access control based upon entity bundle.

Class

EntityBundleLayoutAccess
@file Plugin to provide access control based upon entity bundle.

Code

function checkAccess() {
  if (!$this->settings['bundles']) {
    return FALSE;
  }

  /* @var Entity $entity */
  $entity = $this->contexts[$this->entity_type]->data;
  // Make sure we're testing an entity here. Views could override system
  // paths and cause difficulties.
  // See https://github.com/backdrop/backdrop-issues/issues/5809
  if (!is_object($entity)) {
    $entity = entity_load($this->entity_type, $entity);
  }
  $bundle = $entity->bundle();
  if (!in_array($bundle, $this->settings['bundles'])) {
    return FALSE;
  }

  return TRUE;
}