You are here

protected function SliderAccessControlHandler::checkCreateAccess in Image sliders 8

Separate from the checkAccess because the entity does not yet exist. It will be created during the 'add' process.

Overrides EntityAccessControlHandler::checkCreateAccess

File

src/SliderAccessControlHandler.php, line 47

Class

SliderAccessControlHandler
Access controller for the slider entity.

Namespace

Drupal\image_slider

Code

protected function checkCreateAccess(AccountInterface $account, array $context, $entity_bundle = NULL) {

  // Check the admin_permission as defined in your @ContentEntityType
  // annotation.
  $admin_permission = $this->entityType
    ->getAdminPermission();
  if (\Drupal::currentUser()
    ->hasPermission($admin_permission)) {
    return AccessResult::allowed();
  }
  return AccessResult::allowedIfHasPermission($account, 'add slider entity');
}