public function EntityBreakLockForm::buildForm in Content locking (anti-concurrent editing) 8
Same name and namespace in other branches
- 8.2 src/Form/EntityBreakLockForm.php \Drupal\content_lock\Form\EntityBreakLockForm::buildForm()
Form constructor.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
array The form structure.
Overrides FormInterface::buildForm
File
- src/
Form/ EntityBreakLockForm.php, line 109
Class
- EntityBreakLockForm
- Provides a base class for break content lock forms.
Namespace
Drupal\content_lock\FormCode
public function buildForm(array $form, FormStateInterface $form_state, ContentEntityInterface $entity = NULL, $langcode = NULL, $form_op = NULL) {
// Save langcode of lock, before checking if translation lock is enabled.
// This is needed to generate the correct entity URL for the given language.
$form_state
->set('langcode_entity', $langcode);
$translation_lock = $this->lockService
->isTranslationLockEnabled($entity
->getEntityTypeId());
if (!$translation_lock) {
$langcode = LanguageInterface::LANGCODE_NOT_SPECIFIED;
}
$form_state
->set('translation_lock', $translation_lock);
$form_op_lock = $this->lockService
->isFormOperationLockEnabled($entity
->getEntityTypeId());
if (!$form_op_lock) {
$form_op = '*';
}
$form['#title'] = $this
->t('Break Lock for content @label', [
'@label' => $entity
->label(),
]);
$form['entity_id'] = [
'#type' => 'value',
'#value' => $entity
->id(),
];
$form['entity_type_id'] = [
'#type' => 'value',
'#value' => $entity
->getEntityTypeId(),
];
$form['langcode'] = [
'#type' => 'value',
'#value' => $langcode,
];
$form['form_op'] = [
'#type' => 'value',
'#value' => $form_op,
];
$form['submit'] = [
'#type' => 'submit',
'#value' => $this
->t('Confirm break lock'),
];
return $form;
}