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


PHP EntityInterface::getOwner方法代码示例

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


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

示例1: checkAccess

 /**
  * {@inheritdoc}
  *
  * When the $operation is 'add' then the $entity is of type 'profile_type',
  * otherwise $entity is of type 'profile'.
  */
 protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account)
 {
     $account = $this->prepareUser($account);
     $user_page = \Drupal::request()->attributes->get('user');
     // Some times, operation edit is called update.
     // Use edit in any case.
     if ($operation == 'update') {
         $operation = 'edit';
     }
     // Check that if profile type has require roles, the user the profile is
     // being added to has any of the required roles.
     if ($entity->getEntityTypeId() == 'profile') {
         $profile_roles = ProfileType::load($entity->bundle())->getRoles();
         $user_roles = $entity->getOwner()->getRoles(TRUE);
         if (!empty(array_filter($profile_roles)) && !array_intersect($user_roles, $profile_roles)) {
             return AccessResult::forbidden();
         }
     } elseif ($entity->getEntityTypeId() == 'profile_type') {
         $profile_roles = $entity->getRoles();
         $user_roles = User::load($user_page->id())->getRoles(TRUE);
         if (!empty(array_filter($profile_roles)) && !array_intersect($user_roles, $profile_roles)) {
             return AccessResult::forbidden();
         }
     }
     if ($account->hasPermission('bypass profile access')) {
         return AccessResult::allowed()->cachePerPermissions();
     } elseif ($operation == 'add' && ($user_page->id() == $account->id() && $account->hasPermission($operation . ' own ' . $entity->id() . ' profile') || $account->hasPermission($operation . ' any ' . $entity->id() . ' profile')) || $operation != 'add' && ($entity->getOwnerId() == $account->id() && $account->hasPermission($operation . ' own ' . $entity->getType() . ' profile') || $account->hasPermission($operation . ' any ' . $entity->getType() . ' profile'))) {
         return AccessResult::allowed()->cachePerPermissions();
     } else {
         return AccessResult::forbidden()->cachePerPermissions();
     }
 }
开发者ID:augustpascual-mse,项目名称:job-searching-network,代码行数:38,代码来源:ProfileAccessControlHandler.php

示例2: buildRow

 /**
  * {@inheritdoc}
  */
 public function buildRow(EntityInterface $entity)
 {
     /* @var $entity \Drupal\commerce_order\Entity\Order */
     $orderType = OrderType::load($entity->bundle());
     $row = ['order_id' => $entity->id(), 'type' => $orderType->label(), 'customer' => ['data' => ['#theme' => 'username', '#account' => $entity->getOwner()]], 'state' => $entity->getState()->getLabel(), 'created' => $this->dateFormatter->format($entity->getCreatedTime(), 'short')];
     return $row + parent::buildRow($entity);
 }
开发者ID:alexburrows,项目名称:cream-2.x,代码行数:10,代码来源:OrderListBuilder.php

示例3: 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

示例4: buildRow

 /**
  * {@inheritdoc}
  */
 public function buildRow(EntityInterface $entity)
 {
     $langcode = $entity->language()->getId();
     $uri = $entity->toUrl();
     $options = $uri->getOptions();
     $options += $langcode != LanguageInterface::LANGCODE_NOT_SPECIFIED && isset($languages[$langcode]) ? array('language' => $languages[$langcode]) : array();
     $uri->setOptions($options);
     $row['name']['data'] = array('#type' => 'link', '#title' => $entity->label(), '#url' => $uri);
     $row['display_name'] = $entity->getDisplayName();
     $row['grade_aggregation_type'] = $entity->getGradeAggregationType();
     $row['exclude_empty'] = $entity->getExcludeEmpty() ? t('Yes') : t('No');
     $row['drop_lowest'] = $entity->getDropLowest();
     $row['author']['data'] = array('#theme' => 'username', '#account' => $entity->getOwner());
     return $row + parent::buildRow($entity);
 }
开发者ID:dakala,项目名称:gradebook,代码行数:18,代码来源:GradeCategoryListBuilder.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: buildRow

 /**
  * {@inheritdoc}
  */
 public function buildRow(EntityInterface $entity)
 {
     /** @var \Drupal\profile\Entity\ProfileInterface $entity */
     $mark = ['#theme' => 'mark', '#mark_type' => node_mark($entity->id(), $entity->getChangedTime())];
     $langcode = $entity->language()->id;
     $uri = $entity->toUrl();
     $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' => ' ' . $this->renderer->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:darrylri,项目名称:protovbmwmo,代码行数:27,代码来源:ProfileListBuilder.php

示例7: getAuthor

 /**
  * {@inheritdoc}
  */
 public function getAuthor()
 {
     return $this->translation->hasField('content_translation_uid') ? $this->translation->get('content_translation_uid')->entity : $this->translation->getOwner();
 }
开发者ID:nstielau,项目名称:drops-8,代码行数:7,代码来源:ContentTranslationMetadataWrapper.php

示例8: buildRow

 /**
  * {@inheritdoc}
  *
  * @todo D8-port: add D7-theming to TransitionListBuilder.
  */
 public function buildRow(EntityInterface $transition)
 {
     // Show the history table.
     $current_themed = FALSE;
     /* @var $transition WorkflowTransitionInterface */
     $entity = $transition->getTargetEntity();
     $field_name = $transition->getFieldName();
     $current_sid = workflow_node_current_state($entity, $field_name);
     $to_state = $transition->getToState();
     if (!$to_state) {
         // This is an invalid/deleted state.
         $to_label = WORKFLOW_MARK_STATE_IS_DELETED;
         // Add a footer to explain the addition.
         $this->footer_needed = TRUE;
     } else {
         $label = Html::escape($this->t($to_state->label()));
         if ($transition->getToSid() == $current_sid && $to_state->isActive() && !$current_themed) {
             $to_label = $label;
             if (!$current_themed) {
                 // Make a note that we have themed the current state; other times in the history
                 // of this entity where the entity was in this state do not need to be specially themed.
                 $current_themed = TRUE;
             }
         } elseif (!$to_state->isActive()) {
             $to_label = $label . WORKFLOW_MARK_STATE_IS_DELETED;
             // Add a footer to explain the addition.
             $this->footer_needed = TRUE;
         } else {
             // Regular state.
             $to_label = $label;
         }
     }
     unset($to_state);
     // Not needed anymore.
     $from_state = $transition->getFromState();
     if (!$from_state) {
         // This is an invalid/deleted state.
         $from_label = WORKFLOW_MARK_STATE_IS_DELETED;
         // Add a footer to explain the addition.
         $this->footer_needed = TRUE;
     } else {
         $label = Html::escape($this->t($from_state->label()));
         if (!$from_state->isActive()) {
             $from_label = $label . WORKFLOW_MARK_STATE_IS_DELETED;
             // Add a footer to explain the addition.
             $this->footer_needed = TRUE;
         } else {
             // Regular state.
             $from_label = $label;
         }
     }
     unset($from_state);
     // Not needed anymore.
     $owner = $transition->getOwner();
     $field_name = $transition->getFieldName();
     $field_label = $transition->getFieldName();
     $variables = array('transition' => $transition, 'extra' => '', 'from_label' => $from_label, 'to_label' => $to_label, 'user' => $owner);
     // Allow other modules to modify the row.
     \Drupal::moduleHandler()->alter('workflow_history', $variables);
     //     'class' => array('workflow_history_row'), // TODO D8-port
     $row['timestamp']['data'] = $transition->getTimestampFormatted();
     // 'class' => array('timestamp')
     // html_entity_decode() transforms chars like '&' correctly.
     if ($this->showColumnFieldname($entity)) {
         $row['field_name']['data'] = html_entity_decode($field_label);
     }
     $row['from_state']['data'] = html_entity_decode($from_label);
     // 'class' => array('previous-state-name'))
     $row['to_state']['data'] = html_entity_decode($to_label);
     // 'class' => array('state-name'))
     $row['user_name']['data'] = $owner->getUsername();
     // 'class' => array('user-name')
     $row['comment']['data'] = html_entity_decode($transition->getComment());
     // 'class' => array('log-comment')
     //    $row['comment'] = array(
     //      '#type' => 'textarea',
     //      '#default_value' => $transition->getComment(),
     //    );
     // Column 'Operations' is now added by core.
     // D7: $row['operations']['data'] = $this->buildOperations($entity);
     $row += parent::buildRow($transition);
     return $row;
 }
开发者ID:sedurzu,项目名称:ildeposito8,代码行数:88,代码来源:WorkflowTransitionListBuilder.php

示例9: entitySaveAccess

 /**
  * {@inheritdoc}
  */
 protected function entitySaveAccess(EntityInterface $entity)
 {
     // No need to authorize.
     if (!$this->configuration['authorize'] || !$entity instanceof EntityOwnerInterface) {
         return;
     }
     // If the uid was mapped directly, rather than by email or username, it
     // could be invalid.
     if (!($account = $entity->getOwner())) {
         throw new EntityAccessException($this->t('Invalid user mapped to %label.', ['%label' => $entity->label()]));
     }
     // We don't check access for anonymous users.
     if ($account->isAnonymous()) {
         return;
     }
     $op = $entity->isNew() ? 'create' : 'update';
     // Access granted.
     if ($entity->access($op, $account)) {
         return;
     }
     $args = ['%name' => $account->getUsername(), '@op' => $op, '@bundle' => $this->getItemLabelPlural()];
     throw new EntityAccessException($this->t('User %name is not authorized to @op @bundle.', $args));
 }
开发者ID:Tawreh,项目名称:mtg,代码行数:26,代码来源:EntityProcessorBase.php

示例10: buildRow

  /**
   * {@inheritdoc}
   */
  public function buildRow(EntityInterface $entity) {
    /* @var $entity \Drupal\commerce_payment\Entity\PaymentInfo */
    $paymentInfoType = PaymentInfoType::load($entity->bundle());

    $row = array(
      'information_id' => $entity->id(),
      'payment_method' => $paymentInfoType->label(),
      'owner' => array(
        'data' => array(
          '#theme' => 'username',
          '#account' => $entity->getOwner(),
        ),
      ),
      'status' => $entity->getStatus(),
      'created' => $this->dateFormatter->format($entity->getCreatedTime(), 'short'),
      'changed' => $this->dateFormatter->format($entity->getChangedTime(), 'short'),
    );
    return $row + parent::buildRow($entity);
  }
开发者ID:housineali,项目名称:drpl8_dv,代码行数:22,代码来源:PaymentInfoListBuilder.php

示例11: buildRow

 /**
  * {@inheritdnoc}
  */
 public function buildRow(EntityInterface $payment)
 {
     /** @var \Drupal\payment\Entity\PaymentInterface $payment */
     $row['data']['updated'] = $this->dateFormatter->format($payment->getChangedTime());
     $status_definition = $payment->getPaymentStatus()->getPluginDefinition();
     $row['data']['status'] = $status_definition['label'];
     /** @var \Drupal\currency\Entity\CurrencyInterface $currency */
     $currency = $this->currencyStorage->load($payment->getCurrencyCode());
     if (!$currency) {
         $currency = $this->currencyStorage->load('XXX');
     }
     $row['data']['amount'] = $currency->formatAmount($payment->getAmount());
     $row['data']['payment_method'] = $payment->getPaymentMethod() ? $payment->getPaymentMethod()->getPluginDefinition()['label'] : $this->t('Unavailable');
     $row['data']['owner']['data'] = array('#theme' => 'username', '#account' => $payment->getOwner());
     $operations = $this->buildOperations($payment);
     $row['data']['operations']['data'] = $operations;
     return $row;
 }
开发者ID:nishantkumar155,项目名称:drupal8.crackle,代码行数:21,代码来源:PaymentListBuilder.php


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