You are here

public static function RegistrantsElementUtility::entityCreateAccess in RNG - Events and Registrations 3.x

Same name and namespace in other branches
  1. 8.2 src/RegistrantsElementUtility.php \Drupal\rng\RegistrantsElementUtility::entityCreateAccess()
  2. 8 src/RegistrantsElementUtility.php \Drupal\rng\RegistrantsElementUtility::entityCreateAccess()

Determine whether the current user can create new entities.

Parameters

string $entity_type_id: A entity type ID.

string $bundle: An entity bundle.

Return value

bool Whether the current user can create new entities.

2 calls to RegistrantsElementUtility::entityCreateAccess()
Registrants::processIdentityElement in src/Element/Registrants.php
Process the registrant element.
RegistrantsElementUtility::peopleTypeOptions in src/RegistrantsElementUtility.php
Generate available people type options suitable for radios element.

File

src/RegistrantsElementUtility.php, line 391

Class

RegistrantsElementUtility

Namespace

Drupal\rng

Code

public static function entityCreateAccess($entity_type_id, $bundle) {
  $entity_type_manager = \Drupal::entityTypeManager();
  $entity_type = $entity_type_manager
    ->getDefinition($entity_type_id);
  $access_control = $entity_type_manager
    ->getAccessControlHandler($entity_type_id);

  // If entity type has bundles.
  $entity_bundle = $entity_type
    ->getBundleEntityType() !== NULL ? $bundle : NULL;
  return $access_control
    ->createAccess($entity_bundle);
}