Generic access callback for create entity pages.
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.
bool TRUE if the access is granted. FALSE if access is denied.
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');
}