You are here

protected function ContentLock::lockingSave in Content locking (anti-concurrent editing) 8.2

Same name and namespace in other branches
  1. 8 src/ContentLock/ContentLock.php \Drupal\content_lock\ContentLock\ContentLock::lockingSave()

Save locking into database.

Parameters

int $entity_id: The entity id.

string $langcode: The translation language of the entity.

string $form_op: The entity form operation.

int $uid: The user uid.

string $entity_type: The entity type.

Return value

bool The result of the merge query.

1 call to ContentLock::lockingSave()
ContentLock::locking in src/ContentLock/ContentLock.php
Try to lock a document for editing.

File

src/ContentLock/ContentLock.php, line 303

Class

ContentLock
Class ContentLock.

Namespace

Drupal\content_lock\ContentLock

Code

protected function lockingSave($entity_id, $langcode, $form_op, $uid, $entity_type = 'node') {
  if (!$this
    ->isTranslationLockEnabled($entity_type)) {
    $langcode = LanguageInterface::LANGCODE_NOT_SPECIFIED;
  }
  if (!$this
    ->isFormOperationLockEnabled($entity_type)) {
    $form_op = '*';
  }
  $result = $this->database
    ->merge('content_lock')
    ->key([
    'entity_id' => $entity_id,
    'entity_type' => $entity_type,
    'langcode' => $langcode,
    'form_op' => $form_op,
  ])
    ->fields([
    'entity_id' => $entity_id,
    'entity_type' => $entity_type,
    'langcode' => $langcode,
    'form_op' => $form_op,
    'uid' => $uid,
    'timestamp' => $this->time
      ->getRequestTime(),
  ])
    ->execute();
  return $result;
}