- Issue created by @donquixote
In node_edit_protection_form_alter() we introduce a variable `$class` but then we don't use it.
function node_edit_protection_form_alter(&$form, \Drupal\Core\Form\FormStateInterface &$form_state, $form_id) {
$class = $form['#attributes']['class'] ?? NULL;
if (is_array($class)) {
if (!empty($form['#attributes']['class']) && array_search('node-form', $form['#attributes']['class'])) {
$form['#attached']['library'][] = 'node_edit_protection/node_edit_protection';
}
}
}
function node_edit_protection_form_alter(&$form, \Drupal\Core\Form\FormStateInterface &$form_state, $form_id) {
$class = $form['#attributes']['class'] ?? NULL;
if (is_array($class)) {
if ($class && array_search('node-form', $class)) {
$form['#attached']['library'][] = 'node_edit_protection/node_edit_protection';
}
}
}
This is only one step in improving this code.
Besides not properly using the local var, there are also more severe problems:
Active
1.0
Code