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


PHP ContentEntityInterface::setNewRevision方法代码示例

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


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

示例1: onPresave

 /**
  * {@inheritdoc}
  */
 public function onPresave(ContentEntityInterface $entity, $default_revision, $published_state)
 {
     // This is *probably* not necessary if configuration is setup correctly,
     // but it can't hurt.
     $entity->setNewRevision(TRUE);
     // A newly-created revision is always the default revision, or else
     // it gets lost.
     $entity->isDefaultRevision($entity->isNew() || $default_revision);
 }
开发者ID:tedbow,项目名称:scheduled-updates-demo,代码行数:12,代码来源:ModerationHandler.php

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

示例3: onPresave

 /**
  * {@inheritdoc}
  */
 public function onPresave(ContentEntityInterface $entity, $default_revision, $published_state)
 {
     // This is probably not necessary if configuration is setup correctly.
     $entity->setNewRevision(TRUE);
     $entity->isDefaultRevision($default_revision);
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:9,代码来源:ModerationHandler.php


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