當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ContentEntityInterface::getRevisionCreationTime方法代碼示例

本文整理匯總了PHP中Drupal\Core\Entity\ContentEntityInterface::getRevisionCreationTime方法的典型用法代碼示例。如果您正苦於以下問題:PHP ContentEntityInterface::getRevisionCreationTime方法的具體用法?PHP ContentEntityInterface::getRevisionCreationTime怎麽用?PHP ContentEntityInterface::getRevisionCreationTime使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Drupal\Core\Entity\ContentEntityInterface的用法示例。


在下文中一共展示了ContentEntityInterface::getRevisionCreationTime方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getQuestion

 /**
  * {@inheritdoc}
  */
 public function getQuestion()
 {
     if ($this->entityRevision instanceof TimestampedRevisionInterface) {
         return t('Are you sure you want to delete the revision from %revision-date?', ['%revision-date' => $this->dateFormatter->format($this->entityRevision->getRevisionCreationTime())]);
     } else {
         return t('Are you sure you want to delete to the revision');
     }
 }
開發者ID:heddn,項目名稱:content_entity_base,代碼行數:11,代碼來源:EntityRevisionDeleteForm.php

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

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


注:本文中的Drupal\Core\Entity\ContentEntityInterface::getRevisionCreationTime方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。