book_link_weight-1.0.0-beta1/book_link_weight.module
book_link_weight.module
<?php
/**
* @file
* Hooks to enhance the book with a bool link weight interface.
*/
use Drupal\Core\Form\FormStateInterface;
/**
* Implements hook_form_NODE_FORM_alter().
*/
function book_link_weight_form_node_form_alter(&$form, FormStateInterface $form_state, $form_id) {
if (isset($form['book'])) {
\Drupal::service('book_link_weight.form')->alterBookOutlineForm($form, $form_state);
}
}
/**
* Implements hook_form_alter().
*/
function book_link_weight_form_alter(&$form, FormStateInterface $form_state, $form_id) {
// If this form is the book outline page then add the weight control
// to the form.
// Using this method because the book_outline_form does not provide
// a base form id.
if (substr($form_id, 0, 4) === 'node' && substr($form_id, -17) === 'book_outline_form') {
if (isset($form['book'])) {
\Drupal::service('book_link_weight.form')->alterBookOutlineForm($form, $form_state);
}
}
}
