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


PHP EntityInterface::isActive方法代码示例

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


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

示例1: checkAccess

 /**
  * {@inheritdoc}
  */
 protected function checkAccess(EntityInterface $entity, $operation, $langcode, AccountInterface $account)
 {
     /** @var \Drupal\user\UserInterface $entity*/
     // The anonymous user's profile can neither be viewed, updated nor deleted.
     if ($entity->isAnonymous()) {
         return AccessResult::forbidden();
     }
     // Administrators can view/update/delete all user profiles.
     if ($account->hasPermission('administer users')) {
         return AccessResult::allowed()->cachePerRole();
     }
     switch ($operation) {
         case 'view':
             // Only allow view access if the account is active.
             if ($account->hasPermission('access user profiles') && $entity->isActive()) {
                 return AccessResult::allowed()->cachePerRole()->cacheUntilEntityChanges($entity);
             } else {
                 if ($account->id() == $entity->id()) {
                     return AccessResult::allowed()->cachePerUser();
                 }
             }
             break;
         case 'update':
             // Users can always edit their own account.
             return AccessResult::allowedIf($account->id() == $entity->id())->cachePerUser();
         case 'delete':
             // Users with 'cancel account' permission can cancel their own account.
             return AccessResult::allowedIf($account->id() == $entity->id() && $account->hasPermission('cancel account'))->cachePerRole()->cachePerUser();
     }
     // No opinion.
     return AccessResult::neutral();
 }
开发者ID:Nikola-xiii,项目名称:d8intranet,代码行数:35,代码来源:UserAccessControlHandler.php

示例2: buildRow

 /**
  * {@inheritdoc}
  */
 public function buildRow(EntityInterface $entity)
 {
     $uri = $entity->urlInfo();
     $options = $uri->getOptions();
     $uri->setOptions($options);
     $row['title']['data'] = ['#type' => 'link', '#title' => $entity->label(), '#url' => $uri];
     $row['type'] = SafeMarkup::checkPlain($entity->getType()->label());
     $row['author']['data'] = ['#theme' => 'username', '#account' => $entity->getOwner()];
     $row['status'] = $entity->isActive() ? $this->t('active') : $this->t('not active');
     $row['imported'] = $this->dateFormatter->format($entity->getImportedTime(), 'short');
     $row['operations']['data'] = $this->buildOperations($entity);
     return $row + parent::buildRow($entity);
 }
开发者ID:Tawreh,项目名称:mtg,代码行数:16,代码来源:FeedListBuilder.php

示例3: checkAccess

 /**
  * {@inheritdoc}
  */
 protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account)
 {
     if ($operation === 'delete') {
         return AccessResult::allowedIf($entity->isInactive());
     } else {
         if ($operation == 'abort') {
             return AccessResult::allowedIf($entity->isActive() || $entity->isNeedsReview());
         } else {
             if ($entity->getJob()) {
                 return $entity->getJob()->access($operation, $account, TRUE);
             }
         }
     }
 }
开发者ID:andrewl,项目名称:andrewlnet,代码行数:17,代码来源:JobItemAccessControlHandler.php

示例4: buildRow

 /**
  * {@inheritdoc}
  */
 public function buildRow(EntityInterface $entity)
 {
     $row['username']['data'] = array('#theme' => 'username', '#account' => $entity);
     $row['status'] = $entity->isActive() ? $this->t('active') : $this->t('blocked');
     $roles = array_map('\\Drupal\\Component\\Utility\\String::checkPlain', user_role_names(TRUE));
     unset($roles[DRUPAL_AUTHENTICATED_RID]);
     $users_roles = array();
     foreach ($entity->getRoles() as $role) {
         if (isset($roles[$role])) {
             $users_roles[] = $roles[$role];
         }
     }
     asort($users_roles);
     $row['roles']['data'] = array('#theme' => 'item_list', '#items' => $users_roles);
     $row['member_for'] = format_interval(REQUEST_TIME - $entity->getCreatedTime());
     $row['access'] = $entity->access ? $this->t('@time ago', array('@time' => format_interval(REQUEST_TIME - $entity->getLastAccessedTime()))) : t('never');
     return $row + parent::buildRow($entity);
 }
开发者ID:alnutile,项目名称:drunatra,代码行数:21,代码来源:UserListBuilder.php

示例5: buildRow

 /**
  * {@inheritdoc}
  */
 public function buildRow(EntityInterface $entity)
 {
     /** @var \Drupal\profile\Entity\ProfileInterface $entity */
     $langcode = $entity->language()->getId();
     $uri = $entity->toUrl();
     $options = $uri->getOptions();
     $options += $langcode != LanguageInterface::LANGCODE_NOT_SPECIFIED && isset($languages[$langcode]) ? ['language' => $languages[$langcode]] : [];
     $uri->setOptions($options);
     $row['label'] = $entity->link();
     $row['type'] = $entity->getType();
     $row['owner']['data'] = ['#theme' => 'username', '#account' => $entity->getOwner()];
     $row['status'] = $entity->isActive() ? $this->t('active') : $this->t('not active');
     $row['is_default'] = $entity->isDefault() ? $this->t('default') : $this->t('not default');
     $row['changed'] = $this->dateFormatter->format($entity->getChangedTime(), 'short');
     $language_manager = \Drupal::languageManager();
     if ($language_manager->isMultilingual()) {
         $row['language_name'] = $language_manager->getLanguageName($langcode);
     }
     return $row + parent::buildRow($entity);
 }
开发者ID:nB-MDSO,项目名称:mdso-d8blog,代码行数:23,代码来源:ProfileListBuilder.php

示例6: checkAccess

 /**
  * {@inheritdoc}
  */
 protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account)
 {
     /** @var \Drupal\user\UserInterface $entity*/
     // We don't treat the user label as privileged information, so this check
     // has to be the first one in order to allow labels for all users to be
     // viewed, including the special anonymous user.
     if ($operation === 'view label') {
         return AccessResult::allowed();
     }
     // The anonymous user's profile can neither be viewed, updated nor deleted.
     if ($entity->isAnonymous()) {
         return AccessResult::forbidden();
     }
     // Administrators can view/update/delete all user profiles.
     if ($account->hasPermission('administer users')) {
         return AccessResult::allowed()->cachePerPermissions();
     }
     switch ($operation) {
         case 'view':
             // Only allow view access if the account is active.
             if ($account->hasPermission('access user profiles') && $entity->isActive()) {
                 return AccessResult::allowed()->cachePerPermissions()->addCacheableDependency($entity);
             } elseif ($account->id() == $entity->id()) {
                 return AccessResult::allowed()->cachePerUser();
             }
             break;
         case 'update':
             // Users can always edit their own account.
             return AccessResult::allowedIf($account->id() == $entity->id())->cachePerUser();
         case 'delete':
             // Users with 'cancel account' permission can cancel their own account.
             return AccessResult::allowedIf($account->id() == $entity->id() && $account->hasPermission('cancel account'))->cachePerPermissions()->cachePerUser();
     }
     // No opinion.
     return AccessResult::neutral();
 }
开发者ID:sojo,项目名称:d8_friendsofsilence,代码行数:39,代码来源:UserAccessControlHandler.php

示例7: buildRow

 /**
  * {@inheritdoc}
  *
  * @param \Drupal\rng\RuleInterface $entity
  *   A rule entity.
  */
 public function buildRow(EntityInterface $entity)
 {
     $row['id'] = $entity->id();
     $row['trigger'] = $entity->getTriggerID();
     $row['conditions']['data'] = array('#theme' => 'links', '#links' => [], '#attributes' => ['class' => ['links', 'inline']]);
     foreach ($entity->getConditions() as $condition) {
         $row['conditions']['data']['#links'][] = array('title' => $this->t('Edit', ['@condition_id' => $condition->id(), '@condition' => $condition->getPluginId()]), 'url' => $condition->urlInfo('edit-form'), 'query' => $this->redirectDestination->getAsArray());
     }
     $row['actions']['data'] = array('#theme' => 'links', '#links' => [], '#attributes' => ['class' => ['links', 'inline']]);
     foreach ($entity->getActions() as $action) {
         $row['actions']['data']['#links'][] = array('title' => $this->t('Edit', ['@action_id' => $action->id(), '@action' => $action->getPluginId()]), 'url' => $action->urlInfo('edit-form'), 'query' => $this->redirectDestination->getAsArray());
     }
     $row['status'] = $entity->isActive() ? $this->t('Active') : $this->t('Inactive');
     return $row + parent::buildRow($entity);
 }
开发者ID:justincletus,项目名称:webdrupalpro,代码行数:21,代码来源:RuleListBuilder.php

示例8: buildRow

  /**
   * {@inheritdoc}
   */
  public function buildRow(EntityInterface $entity) {
    /** @var \Drupal\profile\ProfileInterface $entity */
    $mark = [
      '#theme' => 'mark',
      '#mark_type' => node_mark($entity->id(), $entity->getChangedTime()),
    ];
    $langcode = $entity->language()->id;
    $uri = $entity->urlInfo();
    $options = $uri->getOptions();
    $options += ($langcode != LanguageInterface::LANGCODE_NOT_SPECIFIED && isset($languages[$langcode]) ? ['language' => $languages[$langcode]] : []);
    $uri->setOptions($options);
    $row['label']['data'] = [
        '#type' => 'link',
        '#title' => $entity->label(),
        '#suffix' => ' ' . drupal_render($mark),
      ] + $uri->toRenderArray();
    $row['type'] = $entity->getType()->id();
    $row['owner']['data'] = [
      '#theme' => 'username',
      '#account' => $entity->getOwner(),
    ];
    $row['status'] = $entity->isActive() ? $this->t('active') : $this->t('not active');
    $row['changed'] = $this->dateFormatter->format($entity->getChangedTime(), 'short');
    $language_manager = \Drupal::languageManager();
    if ($language_manager->isMultilingual()) {
      $row['language_name'] = $language_manager->getLanguageName($langcode);
    }

    $route_params = ['user' => $entity->getOwnerId(), 'type' => $entity->bundle(), 'profile' => $entity->id()];
    $links['edit'] = [
      'title' => t('Edit'),
      'route_name' => 'entity.profile.edit_form',
      'route_parameters' => $route_params,
    ];
    $links['delete'] = [
      'title' => t('Delete'),
      'route_name' => 'entity.profile.delete_form',
      'route_parameters' => $route_params,
    ];

    $row[] = [
      'data' => [
        '#type' => 'operations',
        '#links' => $links,
      ],
    ];

    return $row + parent::buildRow($entity);
  }
开发者ID:housineali,项目名称:drpl8_dv,代码行数:52,代码来源:ProfileListBuilder.php

示例9: buildRow

 /**
  * {@inheritdoc}
  */
 public function buildRow(EntityInterface $entity)
 {
     $row['username']['data'] = array('#theme' => 'username', '#account' => $entity);
     $row['status'] = $entity->isActive() ? $this->t('active') : $this->t('blocked');
     $roles = user_role_names(TRUE);
     unset($roles[RoleInterface::AUTHENTICATED_ID]);
     $users_roles = array();
     foreach ($entity->getRoles() as $role) {
         if (isset($roles[$role])) {
             $users_roles[] = $roles[$role];
         }
     }
     asort($users_roles);
     $row['roles']['data'] = array('#theme' => 'item_list', '#items' => $users_roles);
     $row['member_for'] = $this->dateFormatter->formatTimeDiffSince($entity->getCreatedTime());
     $row['access'] = $entity->access ? $this->t('@time ago', array('@time' => $this->dateFormatter->formatTimeDiffSince($entity->getLastAccessedTime()))) : t('never');
     return $row + parent::buildRow($entity);
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:21,代码来源:UserListBuilder.php

示例10: buildRow

 /**
  * {@inheritdoc}
  */
 public function buildRow(EntityInterface $entity)
 {
     $row['username']['data'] = array('#theme' => 'username', '#account' => $entity);
     $row['status'] = $entity->isActive() ? $this->t('active') : $this->t('blocked');
     $roles = user_role_names(TRUE);
     unset($roles[RoleInterface::AUTHENTICATED_ID]);
     $users_roles = array();
     foreach ($entity->getRoles() as $role) {
         if (isset($roles[$role])) {
             $users_roles[] = $roles[$role];
         }
     }
     asort($users_roles);
     $row['roles']['data'] = array('#theme' => 'item_list', '#items' => $users_roles);
     $options = ['return_as_object' => TRUE];
     $row['member_for']['data'] = $this->dateFormatter->formatTimeDiffSince($entity->getCreatedTime(), $options)->toRenderable();
     $last_access = $this->dateFormatter->formatTimeDiffSince($entity->getLastAccessedTime(), $options);
     if ($entity->getLastAccessedTime()) {
         $row['access']['data']['#markup'] = $last_access->getString();
         CacheableMetadata::createFromObject($last_access)->applyTo($row['access']['data']);
     } else {
         $row['access']['data']['#markup'] = t('never');
     }
     return $row + parent::buildRow($entity);
 }
开发者ID:sojo,项目名称:d8_friendsofsilence,代码行数:28,代码来源:UserListBuilder.php


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