public function ContentLock::unlockButton 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::unlockButton()
Builds a button class, link type form element to unlock the content.
Parameters
string $entity_type: The entity type of the content.
int $entity_id: The entity id of the content.
string $langcode: The translation language code of the entity.
string $form_op: The entity form operation.
string $destination: The destination query parameter to build the link with.
Return value
array The link form element.
File
- src/
ContentLock/ ContentLock.php, line 561
Class
- ContentLock
- Class ContentLock.
Namespace
Drupal\content_lock\ContentLockCode
public function unlockButton($entity_type, $entity_id, $langcode, $form_op, $destination) {
$unlock_url_options = [];
if ($destination) {
$unlock_url_options['query'] = [
'destination' => $destination,
];
}
$route_parameters = [
'entity' => $entity_id,
'langcode' => $this
->isTranslationLockEnabled($entity_type) ? $langcode : LanguageInterface::LANGCODE_NOT_SPECIFIED,
'form_op' => $this
->isFormOperationLockEnabled($entity_type) ? $form_op : '*',
];
return [
'#type' => 'link',
'#title' => $this
->t('Unlock'),
'#access' => TRUE,
'#attributes' => [
'class' => [
'button',
],
],
'#url' => Url::fromRoute('content_lock.break_lock.' . $entity_type, $route_parameters, $unlock_url_options),
'#weight' => 99,
];
}