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