本文整理汇总了PHP中Drupal\Core\Entity\ContentEntityBase::preSaveRevision方法的典型用法代码示例。如果您正苦于以下问题:PHP ContentEntityBase::preSaveRevision方法的具体用法?PHP ContentEntityBase::preSaveRevision怎么用?PHP ContentEntityBase::preSaveRevision使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\Core\Entity\ContentEntityBase
的用法示例。
在下文中一共展示了ContentEntityBase::preSaveRevision方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testPreSaveRevision
/**
* @covers ::preSaveRevision
*/
public function testPreSaveRevision()
{
// This method is internal, so check for errors on calling it only.
$storage = $this->getMock('\\Drupal\\Core\\Entity\\EntityStorageInterface');
$record = new \stdClass();
// Our mocked entity->preSaveRevision() returns NULL, so assert that.
$this->assertNull($this->entity->preSaveRevision($storage, $record));
}
示例2: preSaveRevision
/**
* {@inheritdoc}
*/
public function preSaveRevision(EntityStorageInterface $storage, \stdClass $record)
{
parent::preSaveRevision($storage, $record);
if (!$this->isNewRevision() && isset($this->original) && (!isset($record->revision_log) || $record->revision_log === '')) {
// If we are updating an existing entity without adding a new
// revision and the user did not supply a revision log, keep the existing
// one.
$record->revision_log = $this->original->getRevisionLog();
}
}
示例3: preSaveRevision
/**
* {@inheritdoc}
*/
public function preSaveRevision(EntityStorageInterface $storage, \stdClass $record)
{
parent::preSaveRevision($storage, $record);
if (!$this->isNewRevision() && isset($this->original) && (!isset($record->revision_log) || $record->revision_log === '')) {
// If we are updating an existing node without adding a new revision, we
// need to make sure $entity->revision_log is reset whenever it is empty.
// Therefore, this code allows us to avoid clobbering an existing log
// entry with an empty one.
$record->revision_log = $this->original->revision_log->value;
}
}
示例4: preSaveRevision
/**
* {@inheritdoc}
*/
public function preSaveRevision(EntityStorageInterface $storage, \stdClass $record)
{
parent::preSaveRevision($storage, $record);
if (!isset($record->revision_log)) {
$record->revision_log = '';
}
$account = \Drupal::currentUser();
$record->uid = $account->id();
}
示例5: preSaveRevision
/**
* {@inheritdoc}
*/
public function preSaveRevision(EntityStorageInterface $storage, \stdClass $record)
{
parent::preSaveRevision($storage, $record);
}