function entity_page_create_access

Generic access callback for create entity pages.

Parameters

string $entity_type: The entity type.

string $bundle: (optional) The bundle of the entity. Required if the entity supports bundles, defaults to the entity type otherwise.

Return value

bool TRUE if the access is granted. FALSE if access is denied.

1 call to entity_page_create_access()
taxonomy_term_create_access in drupal/core/modules/taxonomy/taxonomy.module
Access callback for creating a new taxonomy term.
1 string reference to 'entity_page_create_access'
taxonomy_menu in drupal/core/modules/taxonomy/taxonomy.module
Implements hook_menu().

File

drupal/core/includes/entity.inc, line 827
Entity API for handling entities like nodes or users.

Code

function entity_page_create_access($entity_type, $bundle = NULL) {
  $definition = Drupal::entityManager()
    ->getDefinition($entity_type);

  // Pass in the entity bundle if given and required.
  $values = array();
  if ($bundle && isset($definition['entity_keys']['bundle'])) {
    $values[$definition['entity_keys']['bundle']] = $bundle;
  }
  $entity = Drupal::entityManager()
    ->getStorageController($entity_type)
    ->create($values);
  return $entity
    ->access('create');
}