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


PHP ContentEntityInterface::label方法代码示例

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


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

示例1: submitForm

 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     $this->entityManager->getStorage($this->entityRevision->getEntityTypeId())->deleteRevision($this->entityRevision->getRevisionId());
     $this->logger('content')->notice('@type: deleted %title revision %revision.', ['@type' => $this->entityRevision->bundle(), '%title' => $this->entityRevision->label(), '%revision' => $this->entityRevision->getRevisionId()]);
     drupal_set_message(t('@type %title has been deleted', ['@type' => $this->entityRevision->{$this->entityRevision->getEntityType()->getKey('bundle')}->entity->label(), '%title' => $this->entityRevision->label()]));
     $form_state->setRedirectUrl($this->entityRevision->urlInfo('version-history'));
 }
开发者ID:heddn,项目名称:content_entity_base,代码行数:10,代码来源:EntityRevisionDeleteForm.php

示例2: updateChildren

 /**
  * Update ancestry and ancestry_plain field of any child that has this as its first parent.
  *
  * @var \Drupal\Core\Entity\EntityInterface $discussion
  *    A discussion node that may have had its ancestry updating.
  */
 public function updateChildren(ContentEntityInterface $discussion)
 {
     if ($discussion->hasField('field_parents') && $discussion->hasField('field_ancestry') && $discussion->hasField('field_ancestry_plain')) {
         // If own ancestry has changed, update children's ancestry.
         $newAncestry = $discussion->field_ancestry->getValue();
         $oldAncestry = empty($discussion->original) ? NULL : $discussion->original->field_ancestry->getValue();
         $newTitle = $discussion->label();
         $oldTitle = empty($discussion->original) ? NULL : $discussion->original->label();
         if ($newAncestry !== $oldAncestry || $newTitle !== $oldTitle) {
             $children = $discussion->field_children->referencedEntities();
             $childAncestry = $newAncestry;
             $childAncestry[] = ["target_id" => $discussion->id()];
             foreach ($children as $child) {
                 if ($child->hasField('field_parents') && $child->hasField('field_ancestry') && $child->hasField('field_ancestry_plain')) {
                     // Only update children's ancestry if this is their first parent.
                     if ($child->field_parents->entity->id() === $discussion->id()) {
                         // Only update children's ancestry if child is not already included.
                         // Prevents crazy loops.
                         if (!$this->withinAncestry($child, $childAncestry)) {
                             $child->field_ancestry = $childAncestry;
                         }
                         $child->field_ancestry_plain = $this->makePlain($child->field_ancestry);
                         $child->save();
                     }
                 }
             }
         }
     }
 }
开发者ID:shrimala,项目名称:ahsweb,代码行数:35,代码来源:Ancestry.php

示例3: submitForm

 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     // The revision timestamp will be updated when the revision is saved. Keep
     // the original one for the confirmation message.
     $this->entityRevision->setNewRevision();
     $this->entityRevision->isDefaultRevision(TRUE);
     if ($this->entityRevision instanceof EntityRevisionLogInterface) {
         if ($this->entityRevision instanceof TimestampedRevisionInterface) {
             $original_revision_timestamp = $this->entityRevision->getRevisionCreationTime();
             $this->entityRevision->revision_log = t('Copy of the revision from %date.', ['%date' => $this->dateFormatter->format($original_revision_timestamp)]);
         } else {
             $this->entityRevision->revision_log = t('Copy of the revision');
         }
     }
     $this->entityRevision->save();
     $this->logger('content')->notice('@type: reverted %title revision %revision.', ['@type' => $this->entityRevision->bundle(), '%title' => $this->entityRevision->label(), '%revision' => $this->entityRevision->getRevisionId()]);
     drupal_set_message(t('@type %title has been reverted to the revision', ['@type' => $this->entityRevision->{$this->entityRevision->getEntityType()->getKey('bundle')}->entity->label(), '%title' => $this->entityRevision->label()]));
     $form_state->setRedirectUrl($this->entityRevision->urlInfo('version-history'));
 }
开发者ID:heddn,项目名称:content_entity_base,代码行数:22,代码来源:EntityRevisionRevertForm.php

示例4: getRevisionDescription

 /**
  * {@inheritdoc}
  */
 protected function getRevisionDescription(ContentEntityInterface $revision, $is_default = FALSE)
 {
     /** @var \Drupal\Core\Entity\ContentEntityInterface|\Drupal\user\EntityOwnerInterface|\Drupal\Core\Entity\RevisionLogInterface $revision */
     if ($revision instanceof RevisionLogInterface) {
         // Use revision link to link to revisions that are not active.
         $date = $this->dateFormatter->format($revision->getRevisionCreationTime(), 'short');
         $link = $revision->toLink($date, 'revision');
         // @todo: Simplify this when https://www.drupal.org/node/2334319 lands.
         $username = ['#theme' => 'username', '#account' => $revision->getRevisionUser()];
         $username = $this->renderer->render($username);
     } else {
         $link = $revision->toLink($revision->label(), 'revision');
         $username = '';
     }
     $markup = '';
     if ($revision instanceof RevisionLogInterface) {
         $markup = $revision->getRevisionLogMessage();
     }
     if ($username) {
         $template = '{% trans %}{{ date }} by {{ username }}{% endtrans %}{% if message %}<p class="revision-log">{{ message }}</p>{% endif %}';
     } else {
         $template = '{% trans %} {{ date }} {% endtrans %}{% if message %}<p class="revision-log">{{ message }}</p>{% endif %}';
     }
     $column = ['data' => ['#type' => 'inline_template', '#template' => $template, '#context' => ['date' => $link->toString(), 'username' => $username, 'message' => ['#markup' => $markup, '#allowed_tags' => Xss::getHtmlTagList()]]]];
     return $column;
 }
开发者ID:CIGIHub,项目名称:bsia-drupal8,代码行数:29,代码来源:RevisionOverviewController.php

示例5: getTitle

 /**
  * The title getter.
  *
  * @return string
  *   The title of the event.
  */
 public function getTitle() {
   return $this->entity->label();
 }
开发者ID:AshishNaik021,项目名称:iimisac-d8,代码行数:9,代码来源:CalendarEvent.php

示例6: checkEntityValue

 /**
  * Check an entity value after reload.
  *
  * @param $entity_type_id
  * @param \Drupal\Core\Entity\ContentEntityInterface $entity
  * @param $field
  * @param $value
  */
 protected function checkEntityValue($entity_type_id, ContentEntityInterface $entity, $field, $value) {
   $storage = \Drupal::entityTypeManager()->getStorage($entity_type_id);
   $storage->resetCache([$entity->id()]);
   $updated_entity = $storage->load($entity->id());
   $this->assertEqual($updated_entity->get($field)->value, 1, $entity->label() . " $field = $value");
 }
开发者ID:joebachana,项目名称:usatne,代码行数:14,代码来源:WebTestExtended.php

示例7: generateFilename

 /**
  * Generate a filename from the entity.
  *
  * @param \Drupal\Core\Entity\ContentEntityInterface $entity
  *   The content entity to generate the filename.
  *
  * @return string
  *   The cleaned filename from the entity label.
  */
 protected function generateFilename(ContentEntityInterface $entity)
 {
     $filename = preg_replace("/[^A-Za-z0-9 ]/", '', $entity->label());
     // If for some bizarre reason there isn't a valid character in the entity
     // title or the entity doesn't provide a label then we use the entity type.
     if (!$filename) {
         $filename = $entity->getEntityTypeId();
     }
     return $filename . '.pdf';
 }
开发者ID:gerbreown1,项目名称:calvaryfree,代码行数:19,代码来源:EntityPrintPdfBuilder.php

示例8: getRevisionDescription

 protected function getRevisionDescription(ContentEntityInterface $revision, $is_current = FALSE)
 {
     /** @var \Drupal\Core\Entity\ContentEntityInterface|\Drupal\user\EntityOwnerInterface $revision */
     if ($revision instanceof EntityOwnerInterface) {
         $username = ['#theme' => 'username', '#account' => $revision->getOwner()];
     } else {
         $username = '';
     }
     if ($revision instanceof ExpandedEntityRevisionInterface) {
         // Use revision link to link to revisions that are not active.
         $date = $this->dateFormatter()->format($revision->getRevisionCreationTime(), 'short');
         if (!$is_current) {
             $link = $this->l($date, $revision->urlInfo('revision'));
         } else {
             $link = $revision->link($date);
         }
     } else {
         $link = $revision->link($revision->label(), 'revision');
     }
     $markup = '';
     if ($revision instanceof EntityRevisionLogInterface) {
         $markup = $revision->getRevisionLog();
     }
     if ($username) {
         $template = '{% trans %}{{ date }} by {{ username }}{% endtrans %}{% if message %}<p class="revision-log">{{ message }}</p>{% endif %}';
     } else {
         $template = '{% trans %} {{ date }} {% endtrans %}{% if message %}<p class="revision-log">{{ message }}</p>{% endif %}';
     }
     $column = ['data' => ['#type' => 'inline_template', '#template' => $template, '#context' => ['date' => $link, 'username' => $this->renderer()->renderPlain($username), 'message' => ['#markup' => $markup, '#allowed_tags' => Xss::getHtmlTagList()]]]];
     return $column;
 }
开发者ID:heddn,项目名称:content_entity_base,代码行数:31,代码来源:RevisionController.php

示例9: overviewRow

 /**
  * Builds a table row for overview form.
  *
  * @param array ContentEntityInterface $entity
  *   Data needed to build the list row.
  * @param array $bundles
  *   The array of bundles.
  *
  * @return array
  */
 public function overviewRow(ContentEntityInterface $entity, array $bundles)
 {
     $label = $entity->label() ?: $this->t('@type: @id', array('@type' => $entity->getEntityTypeId(), '@id' => $entity->id()));
     // Get existing translations and current job items for the entity
     // to determine translation statuses
     $translations = $entity->getTranslationLanguages();
     $source_lang = $entity->language()->getId();
     $current_job_items = tmgmt_job_item_load_latest('content', $entity->getEntityTypeId(), $entity->id(), $source_lang);
     $row = array('id' => $entity->id(), 'title' => $entity->hasLinkTemplate('canonical') ? $entity->toLink($label, 'canonical')->toString() : ($entity->label() ?: $entity->id()));
     if (count($bundles) > 1) {
         $row['bundle'] = isset($bundles[$entity->bundle()]) ? $bundles[$entity->bundle()] : t('Unknown');
     }
     // Load entity translation specific data.
     $manager = \Drupal::service('content_translation.manager');
     foreach (\Drupal::languageManager()->getLanguages() as $langcode => $language) {
         $translation_status = 'current';
         if ($langcode == $source_lang) {
             $translation_status = 'original';
         } elseif (!isset($translations[$langcode])) {
             $translation_status = 'missing';
         } elseif ($translation = $entity->getTranslation($langcode)) {
             $metadata = $manager->getTranslationMetadata($translation);
             if ($metadata->isOutdated()) {
                 $translation_status = 'outofdate';
             }
         }
         $build = $this->buildTranslationStatus($translation_status, isset($current_job_items[$langcode]) ? $current_job_items[$langcode] : NULL);
         $row['langcode-' . $langcode] = ['data' => \Drupal::service('renderer')->render($build), 'class' => array('langstatus-' . $langcode)];
     }
     return $row;
 }
开发者ID:andrewl,项目名称:andrewlnet,代码行数:41,代码来源:ContentEntitySourcePluginUi.php


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