예제 #1
0
 /**
  * {@inheritdoc}
  */
 public function buildRow(EntityInterface $entity)
 {
     /** @var \Drupal\conference_sessions\Entity\RoomTypeInterface $entity */
     $product_type = RoomType::load($entity->bundle());
     $row['title']['data'] = ['#type' => 'link', '#title' => $entity->label()] + $entity->toUrl()->toRenderArray();
     $row['type'] = $product_type->label();
     $row['status'] = $entity->isPublished() ? $this->t('Published') : $this->t('Unpublished');
     return $row + parent::buildRow($entity);
 }
예제 #2
0
 /**
  * {@inheritdoc}
  */
 public function entityFormEntityBuild($entity_type, EntityInterface $entity, array $form, FormStateInterface $form_state)
 {
     if ($form_state->hasValue('content_translation')) {
         $translation =& $form_state->getValue('content_translation');
         /** @var \Drupal\comment\CommentInterface $entity */
         $translation['status'] = $entity->isPublished();
         $translation['name'] = $entity->getAuthorName();
     }
     parent::entityFormEntityBuild($entity_type, $entity, $form, $form_state);
 }
예제 #3
0
 /**
  * {@inheritdoc}
  */
 public function entityFormEntityBuild($entity_type, EntityInterface $entity, array $form, FormStateInterface $form_state)
 {
     if ($form_state->hasValue('content_translation')) {
         $translation =& $form_state->getValue('content_translation');
         $translation['status'] = $entity->isPublished();
         $account = $entity->uid->entity;
         $translation['uid'] = $account ? $account->id() : 0;
         $translation['created'] = format_date($entity->created->value, 'custom', 'Y-m-d H:i:s O');
     }
     parent::entityFormEntityBuild($entity_type, $entity, $form, $form_state);
 }
 /**
  * {@inheritdoc}
  */
 protected function checkAccess(EntityInterface $entity, $operation, $langcode, AccountInterface $account)
 {
     /** @var \Drupal\Core\Entity\EntityInterface|\Drupal\user\EntityOwnerInterface $entity */
     switch ($operation) {
         case 'view':
             if ($account->hasPermission('access comments') && $entity->isPublished() || $account->hasPermission('administer comments')) {
                 return $entity->getCommentedEntity()->access($operation, $account);
             }
             break;
         case 'update':
             return $account->id() && $account->id() == $entity->getOwnerId() && $entity->isPublished() && $account->hasPermission('edit own comments') || $account->hasPermission('administer comments');
             break;
         case 'delete':
             return $account->hasPermission('administer comments');
             break;
         case 'approve':
             return $account->hasPermission('administer comments');
             break;
     }
 }
예제 #5
0
  /**
   * {@inheritdoc}
   */
  public function buildRow(EntityInterface $entity) {
    /* @var $entity \Drupal\commerce_product\Entity\Product */
    $productType = ProductType::load($entity->bundle());

    $row['title']['data'] = [
      '#type' => 'link',
      '#title' => $entity->label(),
    ] + $entity->urlInfo()->toRenderArray();
    $row['type'] = $productType->label();
    $row['status'] = $entity->isPublished() ? $this->t('Published') : $this->t('Unpublished');

    return $row + parent::buildRow($entity);
  }
예제 #6
0
 /**
  * {@inheritdoc}
  */
 public function entityFormEntityBuild($entity_type, EntityInterface $entity, array $form, FormStateInterface $form_state)
 {
     if ($form_state->hasValue('content_translation')) {
         $translation =& $form_state->getValue('content_translation');
         $translation['status'] = $entity->isPublished();
         // $form['content_translation']['name'] is the equivalent field
         // for translation author uid.
         $account = $entity->uid->entity;
         $translation['name'] = $account ? $account->getUsername() : '';
         $translation['created'] = format_date($entity->created->value, 'custom', 'Y-m-d H:i:s O');
     }
     parent::entityFormEntityBuild($entity_type, $entity, $form, $form_state);
 }
 /**
  * {@inheritdoc}
  */
 protected function checkAccess(EntityInterface $support_ticket, $operation, AccountInterface $account)
 {
     /** @var \Drupal\support_ticket\SupportTicketInterface $support_ticket */
     // Fetch information from the support_ticket object if possible.
     $status = $support_ticket->isPublished();
     $uid = $support_ticket->getOwnerId();
     // Check if authors can view their own unpublished support tickets.
     if ($operation === 'view' && !$status && $account->hasPermission('view own unpublished support tickets') && $account->isAuthenticated() && $account->id() == $uid) {
         return AccessResult::allowed()->cachePerPermissions()->cachePerUser()->cacheUntilEntityChanges($support_ticket);
     }
     if ($operation === 'view') {
         return AccessResult::allowedIf($status)->cacheUntilEntityChanges($support_ticket);
     }
     // No opinion.
     return AccessResult::neutral();
 }
 /**
  * {@inheritdoc}
  */
 protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account)
 {
     /** @var \Drupal\custom_page\CustomPageInterface $entity */
     switch ($operation) {
         case 'view':
             if (!$entity->isPublished()) {
                 return AccessResult::allowedIfHasPermission($account, 'view unpublished custom page entities');
             }
             return AccessResult::allowedIfHasPermission($account, 'view published custom page entities');
         case 'update':
             return AccessResult::allowedIfHasPermission($account, 'edit custom page entities');
         case 'delete':
             return AccessResult::allowedIfHasPermission($account, 'delete custom page entities');
     }
     // Unknown operation, no opinion.
     return AccessResult::neutral();
 }
 /**
  * {@inheritdoc}
  *
  * Link the activities to the permissions. checkAccess is called with the
  * $operation as defined in the routing.yml file.
  */
 protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account)
 {
     if (!$entity instanceof RdfInterface) {
         throw new \Exception('Can only handle access of Rdf entity instances.');
     }
     $entity_bundle = $entity->bundle();
     switch ($operation) {
         case 'view':
             if (!$entity->isPublished()) {
                 return AccessResult::allowedIfHasPermission($account, 'view unpublished rdf entity');
             }
             return AccessResult::allowedIfHasPermission($account, 'view rdf entity');
         case 'edit':
             return AccessResult::allowedIfHasPermission($account, 'edit ' . $entity_bundle . ' rdf entity');
         case 'delete':
             return AccessResult::allowedIfHasPermission($account, 'delete ' . $entity_bundle . ' rdf entity');
     }
     return AccessResult::neutral();
 }
 /**
  * {@inheritdoc}
  */
 protected function checkAccess(EntityInterface $node, $operation, AccountInterface $account)
 {
     /** @var \Drupal\node\NodeInterface $node */
     // Fetch information from the node object if possible.
     $status = $node->isPublished();
     $uid = $node->getOwnerId();
     // Check if authors can view their own unpublished nodes.
     if ($operation === 'view' && !$status && $account->hasPermission('view own unpublished content') && $account->isAuthenticated() && $account->id() == $uid) {
         return AccessResult::allowed()->cachePerPermissions()->cachePerUser()->addCacheableDependency($node);
     }
     // Evaluate node grants.
     return $this->grantStorage->access($node, $operation, $account);
 }
예제 #11
0
 /**
  * {@inheritdoc}
  */
 public function buildRow(EntityInterface $entity)
 {
     /* @var $entity \Drupal\rdf_entity\Entity\Rdf */
     $row['id'] = $entity->link();
     $row['rid'] = $entity->bundle();
     $row['status'] = $entity->isPublished() ? $this->t('Published') : $this->t('Unpublished');
     return $row + parent::buildRow($entity);
 }