diff --git a/custom_body_class.module b/custom_body_class.module index 002a1ab..8d5cb9c 100644 --- a/custom_body_class.module +++ b/custom_body_class.module @@ -9,9 +9,7 @@ */ use Drupal\Core\Entity\EntityTypeInterface; -use Drupal\node\NodeTypeInterface; use Drupal\Core\Field\BaseFieldDefinition; -use Drupal\Core\Form\FormStateInterface; /** * Implements hook_form_FORM_ID_alter(). @@ -32,41 +30,6 @@ function custom_body_class_form_node_form_alter(&$form, &$form_state, $form_id) } /** - * Implements hook_form_FORM_ID_alter(). - */ -function custom_body_class_form_alter(&$form, FormStateInterface &$form_state, $form_id) { - if ($form_id == 'node_type_edit_form') { - /** @var \Drupal\node\NodeTypeInterface $type */ - $type = $form_state->getFormObject()->getEntity(); - $classes = $type->getThirdPartySetting('node_type_class', 'classes', ''); - $form['nodetype_body_class_group'] = [ - '#type' => 'details', - '#title' => t('Custom Body Class Settings'), - '#group' => 'additional_settings', - '#attached' => [ - 'library' => ['node_type_class/node_type_class.classes'] - ] - ]; - $form['nodetype_body_class_group']['nodetype_class'] = [ - '#title' => t('CSS class(es)'), - '#type' => 'textfield', - '#description' => t('To add multiple classes, separate them with a space.'), - '#default_value' => $classes, - ]; - $form['#entity_builders'][] = 'custom_body_class_form_node_type_form_builder'; - $form['#validate'][] = '_node_special_character_form_validate'; - - } -} - -/** - * Entity builder for the node type form with Custom Node type class. - */ -function custom_body_class_form_node_type_form_builder($entity_type, NodeTypeInterface $type, &$form, FormStateInterface $form_state) { - $type->setThirdPartySetting('node_type_class', 'classes', $form_state->getValue('nodetype_class')); -} - -/** * Implements hook_entity_base_field_info(). */ function custom_body_class_entity_base_field_info(EntityTypeInterface $entity_type) { @@ -105,9 +68,6 @@ function custom_body_class_preprocess_html(&$variables) { if (!empty($specific_node_class) && ($specific_node_class->getValue() !== NULL) && ($specific_node_class->getValue()['value'] == 1)) { $variables['attributes']['class'][] = $node->gettype(); } - $type = \Drupal::service('entity.manager')->getStorage('node_type')->load($node->getType()); - $classes = $type->getThirdPartySetting('node_type_class', 'classes', ''); - $variables['attributes']['class'][] = $classes; } }