Esempio n. 1
0
 /**
  * Checks access to the eck entity add page for the entity bundle type.
  *
  * @param AccountInterface $account
  *   The currently logged in account.
  * @param EckEntityTypeInterface $eck_entity_type
  *   The entity type.
  * @param string $eck_entity_bundle
  *   (optional) The entity type bundle.
  *
  * @return bool|AccessResult|\Drupal\Core\Access\AccessResultInterface
  *   A \Drupal\Core\Access\AccessInterface constant value.
  */
 public function access(AccountInterface $account, EckEntityTypeInterface $eck_entity_type, $eck_entity_bundle = NULL)
 {
     $access_control_handler = $this->entityManager->getAccessControlHandler($eck_entity_type->id());
     if (!empty($eck_entity_bundle)) {
         return $access_control_handler->createAccess($eck_entity_bundle, $account, array(), TRUE);
     }
     // Get the entity type bundles.
     $bundles = $this->entityManager->getStorage($eck_entity_type->id() . '_type')->loadMultiple();
     // If checking whether an entity of any type may be created.
     foreach ($bundles as $eck_entity_bundle) {
         if (($access = $access_control_handler->createAccess($eck_entity_bundle->id(), $account, array(), TRUE)) && $access->isAllowed()) {
             return $access;
         }
     }
     // No opinion.
     return AccessResult::neutral();
 }
Esempio n. 2
0
 /**
  * Title callback for add page.
  *
  * @param EckEntityTypeInterface $eck_entity_type
  *   The entity type.
  *
  * @return string
  *   The title.
  */
 public function addPageTitle(EckEntityTypeInterface $eck_entity_type)
 {
     return t('Add %label content', array('%label' => $eck_entity_type->label()));
 }