public function ContentLock::fetchLock in Content locking (anti-concurrent editing) 8
Same name and namespace in other branches
- 8.2 src/ContentLock/ContentLock.php \Drupal\content_lock\ContentLock\ContentLock::fetchLock()
Fetch the lock for an entity.
Parameters
int $entity_id: The entity id.
string $langcode: The translation language code of the entity.
string $form_op: (optional) The entity form operation.
string $entity_type: The entity type.
Return value
object The lock for the node. FALSE, if the document is not locked.
1 call to ContentLock::fetchLock()
- ContentLock::locking in src/
ContentLock/ ContentLock.php - Try to lock a document for editing.
File
- src/
ContentLock/ ContentLock.php, line 153
Class
- ContentLock
- Class ContentLock.
Namespace
Drupal\content_lock\ContentLockCode
public function fetchLock($entity_id, $langcode, $form_op = NULL, $entity_type = 'node') {
if (!$this
->isTranslationLockEnabled($entity_type)) {
$langcode = LanguageInterface::LANGCODE_NOT_SPECIFIED;
}
if (!$this
->isFormOperationLockEnabled($entity_type)) {
$form_op = '*';
}
$query = $this->database
->select('content_lock', 'c');
$query
->leftJoin('users_field_data', 'u', '%alias.uid = c.uid');
$query
->fields('c')
->fields('u', [
'name',
])
->condition('c.entity_type', $entity_type)
->condition('c.entity_id', $entity_id)
->condition('c.langcode', $langcode);
if (isset($form_op)) {
$query
->condition('c.form_op', $form_op);
}
return $query
->execute()
->fetchObject();
}