当前位置: 首页>>代码示例>>PHP>>正文


PHP EntityInterface::isPublished方法代码示例

本文整理汇总了PHP中Drupal\Core\Entity\EntityInterface::isPublished方法的典型用法代码示例。如果您正苦于以下问题:PHP EntityInterface::isPublished方法的具体用法?PHP EntityInterface::isPublished怎么用?PHP EntityInterface::isPublished使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Drupal\Core\Entity\EntityInterface的用法示例。


在下文中一共展示了EntityInterface::isPublished方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: buildRow

 /**
  * {@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);
 }
开发者ID:mglaman,项目名称:drupalcamp-base,代码行数:12,代码来源:RoomListBuilder.php

示例2: entityFormEntityBuild

 /**
  * {@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);
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:13,代码来源:CommentTranslationHandler.php

示例3: entityFormEntityBuild

 /**
  * {@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);
 }
开发者ID:sarahwillem,项目名称:OD8,代码行数:14,代码来源:NodeTranslationHandler.php

示例4: checkAccess

 /**
  * {@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;
     }
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:23,代码来源:CommentAccessController.php

示例5: buildRow

  /**
   * {@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);
  }
开发者ID:housineali,项目名称:drpl8_dv,代码行数:16,代码来源:ProductListBuilder.php

示例6: entityFormEntityBuild

 /**
  * {@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);
 }
开发者ID:nsp15,项目名称:Drupal8,代码行数:16,代码来源:NodeTranslationHandler.php

示例7: checkAccess

 /**
  * {@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();
 }
开发者ID:justincletus,项目名称:webdrupalpro,代码行数:19,代码来源:SupportTicketAccessControlHandler.php

示例8: checkAccess

 /**
  * {@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();
 }
开发者ID:poetic,项目名称:clutch,代码行数:20,代码来源:CustomPageAccessControlHandler.php

示例9: checkAccess

 /**
  * {@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();
 }
开发者ID:ec-europa,项目名称:joinup-dev,代码行数:25,代码来源:RdfAccessControlHandler.php

示例10: checkAccess

 /**
  * {@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);
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:16,代码来源:NodeAccessControlHandler.php

示例11: buildRow

 /**
  * {@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);
 }
开发者ID:ec-europa,项目名称:joinup-dev,代码行数:11,代码来源:RdfListBuilder.php


注:本文中的Drupal\Core\Entity\EntityInterface::isPublished方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。