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


PHP Entity\EntityInterface类代码示例

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


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

示例1: updateStatus

 /**
  * Entity builder: updates the product status with the submitted value.
  *
  * @param string $entity_type
  *   The entity type.
  * @param \Drupal\commerce_product\Entity\ProductInterface $entity
  *   The product updated with the submitted values.
  * @param array $form
  *   The complete form array.
  * @param \Drupal\Core\Form\FormStateInterface $form_state
  *   The current state of the form.
  *
  * @see \Drupal\node\NodeForm::form()
  */
 public static function updateStatus($entity_type, EntityInterface $entity, array $form, FormStateInterface $form_state)
 {
     $element = $form_state->getTriggeringElement();
     if (isset($element['#published_status'])) {
         $entity->setPublished($element['#published_status']);
     }
 }
开发者ID:mglaman,项目名称:drupalcamp-base,代码行数:21,代码来源:EnhancedContentEntityFormBase.php

示例2: buildRow

 /**
  * {@inheritdoc}
  */
 public function buildRow(EntityInterface $entity)
 {
     /* @var $entity \Drupal\brand\Entity\brand */
     $row['id'] = $entity->id();
     $row['name'] = \Drupal::l($this->getLabel($entity), new Url('entity.brand.edit_form', array('brand' => $entity->id())));
     return $row + parent::buildRow($entity);
 }
开发者ID:ashkarrrahman,项目名称:brand,代码行数:10,代码来源:brandListController.php

示例3: renderLink

 /**
  * Alters the field to render a link.
  *
  * @param \Drupal\Core\Entity\EntityInterface $entity
  * @param \Drupal\views\ResultRow $values
  *   The current row of the views result.
  *
  * @return string
  *   The acutal rendered text (without the link) of this field.
  */
 protected function renderLink(EntityInterface $entity, ResultRow $values)
 {
     $text = !empty($this->options['text']) ? $this->options['text'] : t('View');
     $this->options['alter']['make_link'] = TRUE;
     $this->options['alter']['path'] = $entity->getSystemPath();
     return $text;
 }
开发者ID:alnutile,项目名称:drunatra,代码行数:17,代码来源:Link.php

示例4: getForm

 /**
  * {@inheritdoc}
  */
 public function getForm(EntityInterface $entity, $operation = 'default', array $form_state_additions = array())
 {
     $form_object = $this->entityManager->getFormObject($entity->getEntityTypeId(), $operation);
     $form_object->setEntity($entity);
     $form_state = (new FormState())->setFormState($form_state_additions);
     return $this->formBuilder->buildForm($form_object, $form_state);
 }
开发者ID:318io,项目名称:318-io,代码行数:10,代码来源:EntityFormBuilder.php

示例5: renderLink

 /**
  * Prepares the link to the profile.
  *
  * @param \Drupal\Core\Entity\EntityInterface $profile
  *   The profile entity this field belongs to.
  * @param ResultRow $values
  *   The values retrieved from the view's result set.
  *
  * @return string
  *   Returns a string for the link text.
  */
 protected function renderLink($profile, ResultRow $values) {
   if ($profile->access('view')) {
     $this->options['alter']['make_link'] = TRUE;
     $this->options['alter']['path'] = 'profile/' . $profile->id();
     return $profile->label();
   }
 }
开发者ID:housineali,项目名称:drpl8_dv,代码行数:18,代码来源:Label.php

示例6: getLabelAndConfig

 /**
  * Renders the Metatag defaults lable plus its configuration.
  *
  * @param EntityInterface $entity
  *   The Metatag defaults entity.
  * @return
  *   Render array for a table cell.
  */
 public function getLabelAndConfig(EntityInterface $entity)
 {
     $output = '<div>';
     $prefix = '';
     $inherits = '';
     if ($entity->id() != 'global') {
         $prefix = '<div class="indentation"></div>';
         $inherits .= 'Global';
     }
     if (strpos($entity->id(), '__') !== FALSE) {
         $prefix .= '<div class="indentation"></div>';
         list($entity_label, $bundle_label) = explode(': ', $entity->get('label'));
         $inherits .= ', ' . $entity_label;
     }
     $output .= '<div>
               <p>Inherits meta tags from: ' . $inherits . '</p>
             </div>';
     $tags = $entity->get('tags');
     if (count($tags)) {
         $output .= '<table>
                 <tbody>';
         foreach ($tags as $tag_id => $tag_value) {
             $output .= '<tr><td>' . $tag_id . ':</td><td>' . $tag_value . '</td></tr>';
         }
         $output .= '</tbody></table>';
     }
     $output .= '</div></div>';
     return array('data' => array('#type' => 'details', '#prefix' => $prefix, '#title' => $this->getLabel($entity), 'config' => array('#markup' => $output)));
 }
开发者ID:darrylri,项目名称:protovbmwmo,代码行数:37,代码来源:MetatagDefaultsListBuilder.php

示例7: buildRow

 /**
  * {@inheritdoc}
  */
 public function buildRow(EntityInterface $entity)
 {
     /* @var $entity \Drupal\eck\Entity\EckEntity */
     $row['id'] = $entity->id();
     $row['title'] = \Drupal::l($this->getLabel($entity), Url::fromRoute('entity.' . $this->entityTypeId . '.canonical', array($this->entityTypeId => $entity->id())));
     return array_merge($row, parent::buildRow($entity));
 }
开发者ID:jokas,项目名称:d8.dev,代码行数:10,代码来源:EckEntityListBuilder.php

示例8: buildRow

 /**
  * {@inheritdoc}
  */
 public function buildRow(EntityInterface $entity)
 {
     /* @var $entity \Drupal\my_first_entity\Entity\Course */
     $row['id'] = $entity->id();
     $row['name'] = \Drupal::l($this->getLabel($entity), new Url('entity.course.edit_form', array('course' => $entity->id())));
     return $row + parent::buildRow($entity);
 }
开发者ID:vinhgiang,项目名称:Learning-Drupal-8,代码行数:10,代码来源:CourseListController.php

示例9: checkAccess

 /**
  * {@inheritdoc}
  */
 protected function checkAccess(EntityInterface $entity, $operation, $langcode, AccountInterface $account)
 {
     if ($operation == 'delete' && $entity->getFieldStorageDefinition()->isLocked()) {
         return FALSE;
     }
     return $account->hasPermission('administer ' . $entity->entity_type . ' fields');
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:10,代码来源:FieldInstanceConfigAccessController.php

示例10: buildRow

 /**
  * {@inheritdoc}
  */
 public function buildRow(EntityInterface $entity)
 {
     $row['label'] = $entity->label();
     $row['id'] = $entity->id();
     // You probably want a few more properties here...
     return $row + parent::buildRow($entity);
 }
开发者ID:emilienGallet,项目名称:DrupalUnicef,代码行数:10,代码来源:DefaultEntityListBuilder.php

示例11: isModeratedEntity

 /**
  * {@inheritdoc}
  */
 public function isModeratedEntity(EntityInterface $entity)
 {
     if (!$entity instanceof ContentEntityInterface) {
         return FALSE;
     }
     return $this->shouldModerateEntitiesOfBundle($entity->getEntityType(), $entity->bundle());
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:10,代码来源:ModerationInformation.php

示例12: checkAccess

 /**
  * {@inheritdoc}
  */
 protected function checkAccess(EntityInterface $payment, $operation, AccountInterface $account)
 {
     /** @var \Drupal\payment\Entity\PaymentInterface $payment */
     if ($operation == 'update_status') {
         $payment_method = $payment->getPaymentMethod();
         if ($payment_method instanceof PaymentMethodUpdatePaymentStatusInterface && !$payment_method->updatePaymentStatusAccess($account)) {
             return AccessResult::forbidden();
         }
     } elseif ($operation == 'capture') {
         $payment_method = $payment->getPaymentMethod();
         if ($payment_method instanceof PaymentMethodCapturePaymentInterface) {
             return AccessResult::allowedIf($payment_method instanceof PaymentMethodCapturePaymentInterface)->andIf(AccessResult::allowedIf($payment_method->capturePaymentAccess($account)))->andIf($this->checkAccessPermission($payment, $operation, $account));
         }
         return AccessResult::forbidden();
     } elseif ($operation == 'refund') {
         $payment_method = $payment->getPaymentMethod();
         if ($payment_method instanceof PaymentMethodRefundPaymentInterface) {
             return AccessResult::allowedIf($payment_method->refundPaymentAccess($account))->andIf($this->checkAccessPermission($payment, $operation, $account));
         }
         return AccessResult::forbidden();
     } elseif ($operation == 'complete') {
         if ($payment->getPaymentMethod()) {
             return AccessResult::allowedIf($payment->getOwnerId() == $account->id())->orIf(AccessResult::forbiddenIf($payment->getPaymentMethod()->getPaymentExecutionResult()->isCompleted()));
         } else {
             return AccessResult::forbidden();
         }
     }
     return $this->checkAccessPermission($payment, $operation, $account);
 }
开发者ID:nishantkumar155,项目名称:drupal8.crackle,代码行数:32,代码来源:PaymentAccessControlHandler.php

示例13: buildRow

 /**
  * {@inheritdoc}
  */
 public function buildRow(EntityInterface $entity)
 {
     /* @var $entity \Drupal\dinodb\Entity\Dinosaur */
     $row['id'] = $entity->id();
     $row['name'] = $this->l($this->getLabel($entity), new Url('entity.dinosaur.edit_form', array('dinosaur' => $entity->id())));
     return $row + parent::buildRow($entity);
 }
开发者ID:joshuataylor,项目名称:dinodb,代码行数:10,代码来源:DinosaurListBuilder.php

示例14: checkAccess

 /**
  * {@inheritdoc}
  */
 protected function checkAccess(EntityInterface $filter_format, $operation, $langcode, AccountInterface $account)
 {
     /** @var \Drupal\filter\FilterFormatInterface $filter_format */
     // All users are allowed to use the fallback filter.
     if ($operation == 'use') {
         if ($filter_format->isFallbackFormat()) {
             return AccessResult::allowed();
         } else {
             return AccessResult::allowedIfHasPermission($account, $filter_format->getPermissionName());
         }
     }
     // The fallback format may not be disabled.
     if ($operation == 'disable' && $filter_format->isFallbackFormat()) {
         return AccessResult::forbidden();
     }
     // We do not allow filter formats to be deleted through the UI, because that
     // would render any content that uses them unusable.
     if ($operation == 'delete') {
         return AccessResult::forbidden();
     }
     if (in_array($operation, array('disable', 'update'))) {
         return parent::checkAccess($filter_format, $operation, $langcode, $account);
     }
     // No opinion.
     return AccessResult::neutral();
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:29,代码来源:FilterFormatAccessControlHandler.php

示例15: buildRow

 /**
  * {@inheritdoc}
  */
 public function buildRow(EntityInterface $entity)
 {
     $row['type'] = $entity->link();
     $row['registration'] = $entity->getRegistration() ? t('Yes') : t('No');
     $row['multiple'] = $entity->getMultiple() ? t('Yes') : t('No');
     return $row + parent::buildRow($entity);
 }
开发者ID:darrylri,项目名称:protovbmwmo,代码行数:10,代码来源:ProfileTypeListBuilder.php


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