public function ContentLock::displayLockOwner 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::displayLockOwner()
Tell who has locked node.
Parameters
object $lock: The lock for a node.
bool $translation_lock: Defines whether the lock is on translation level or not.
Return value
string String with the message.
1 call to ContentLock::displayLockOwner()
- ContentLock::locking in src/
ContentLock/ ContentLock.php - Try to lock a document for editing.
File
- src/
ContentLock/ ContentLock.php, line 185
Class
- ContentLock
- Class ContentLock.
Namespace
Drupal\content_lock\ContentLockCode
public function displayLockOwner($lock, $translation_lock) {
$username = $this->entityTypeManager
->getStorage('user')
->load($lock->uid);
$date = $this->dateFormatter
->formatInterval(REQUEST_TIME - $lock->timestamp);
if ($translation_lock) {
$message = $this
->t('This content translation is being edited by the user @name and is therefore locked to prevent other users changes. This lock is in place since @date.', [
'@name' => $username
->getDisplayName(),
'@date' => $date,
]);
}
else {
$message = $this
->t('This content is being edited by the user @name and is therefore locked to prevent other users changes. This lock is in place since @date.', [
'@name' => $username
->getDisplayName(),
'@date' => $date,
]);
}
return $message;
}