本文整理匯總了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);
}
示例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'));
}
示例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);
}