commit 1fdf9f0da76a885d3f4eebc656525ae3db165826 Author: Samuel Leathers Date: Thu Aug 29 10:50:03 2013 -0600 adding parent form to book manager diff --git a/core/modules/book/lib/Drupal/book/BookManager.php b/core/modules/book/lib/Drupal/book/BookManager.php index 3625341..b2f66ce 100644 --- a/core/modules/book/lib/Drupal/book/BookManager.php +++ b/core/modules/book/lib/Drupal/book/BookManager.php @@ -142,7 +142,7 @@ public function linkDefaults($nid) { /** * Finds the depth limit for items in the parent select. * - * @param $book_link + * @param array $book_link * A fully loaded menu link that is part of the book hierarchy. * * @return int @@ -167,7 +167,7 @@ public function parentDepthLimit($book_link) { * @return array * The form structure, with the book elements added. */ - public function addFormElements(array $form, array &$form_state, NodeInterface $node, AccountInterface $account) { + public function addFormElements(array &$form, array &$form_state, NodeInterface $node, AccountInterface $account) { // If the form is being processed during the Ajax callback of our book bid // dropdown, then $form_state will hold the value that was selected. if (isset($form_state['values']['book'])) { @@ -354,6 +354,8 @@ public function updateOutline(NodeInterface $node) { * * @return string * The translated string. + * + * @todo Remove when https://drupal.org/node/2018411 is in. */ protected function t($string, array $args = array(), array $options = array()) { return $this->translation->translate($string, $args, $options); @@ -375,7 +377,7 @@ public function createMenuName($id) { /** * Updates the book ID of a page and its children when it moves to a new book. * - * @param $book_link + * @param array $book_link * A fully loaded menu link that is part of the book hierarchy. */ function updateID($book_link) { @@ -401,7 +403,7 @@ function updateID($book_link) { * Ajax callback, so an array is returned that can be used to replace an * existing form element. * - * @param $book_link + * @param array $book_link * A fully loaded menu link that is part of the book hierarchy. * * @return diff --git a/core/modules/book/lib/Drupal/book/Form/BookOutlineForm.php b/core/modules/book/lib/Drupal/book/Form/BookOutlineForm.php index b60ef0f..acbac8c 100644 --- a/core/modules/book/lib/Drupal/book/Form/BookOutlineForm.php +++ b/core/modules/book/lib/Drupal/book/Form/BookOutlineForm.php @@ -21,7 +21,7 @@ class BookOutlineForm extends EntityFormControllerNG { * * @var \Drupal\node\NodeInterface */ - protected $entity; + protected $node; /** * BookManager service. @@ -58,21 +58,21 @@ public function getBaseFormID() { * {@inheritdoc} */ public function form(array $form, array &$form_state) { - $form['#title'] = $this->entity->label(); + $form['#title'] = $this->node->label(); - if (!isset($this->entity->book)) { + if (!isset($this->node->book)) { // The node is not part of any book yet - set default options. - $this->entity->book = $this->bookManager->linkDefaults($this->entity->id()); + $this->node->book = $this->bookManager->linkDefaults($this->node->id()); } else { - $this->entity->book['original_bid'] = $this->entity->book['bid']; + $this->node->book['original_bid'] = $this->node->book['bid']; } // Find the depth limit for the parent select. - if (!isset($this->entity->book['parent_depth_limit'])) { - $this->entity->book['parent_depth_limit'] = $this->bookManager->parentDepthLimit($this->entity->book); + if (!isset($this->node->book['parent_depth_limit'])) { + $this->node->book['parent_depth_limit'] = $this->bookManager->parentDepthLimit($this->node->book); } - $form = $this->bookManager->addFormElements($form, $form_state, $this->entity, $this->getCurrentUser()); + $this->bookManager->addFormElements($form, $form_state, $this->node, $this->getCurrentUser()); return $form; } @@ -82,9 +82,9 @@ public function form(array $form, array &$form_state) { */ protected function actions(array $form, array &$form_state) { $actions = parent::actions($form, $form_state); - $actions['submit']['#value'] = $this->entity->book['original_bid'] ? $this->t('Update book outline') : $this->t('Add to book outline'); + $actions['submit']['#value'] = $this->node->book['original_bid'] ? $this->t('Update book outline') : $this->t('Add to book outline'); $actions['delete']['#value'] = $this->t('Remove from book outline'); - $actions['delete']['#access'] = $this->bookManager->nodeIsRemovable($this->entity); + $actions['delete']['#access'] = $this->bookManager->nodeIsRemovable($this->node); return $actions; } @@ -94,7 +94,7 @@ protected function actions(array $form, array &$form_state) { * @see book_remove_button_submit() */ public function submit(array $form, array &$form_state) { - $form_state['redirect'] = 'node/' . $this->entity->id(); + $form_state['redirect'] = 'node/' . $this->node->id(); $book_link = $form_state['values']['book']; if (!$book_link['bid']) { drupal_set_message($this->t('No changes were made')); @@ -102,12 +102,12 @@ public function submit(array $form, array &$form_state) { } $book_link['menu_name'] = $this->bookManager->createMenuName($book_link['bid']); - $this->entity->book = $book_link; - if ($this->bookManager->updateOutline($this->entity)) { - if ($this->entity->book['parent_mismatch']) { + $this->node->book = $book_link; + if ($this->bookManager->updateOutline($this->node)) { + if ($this->node->book['parent_mismatch']) { // This will usually only happen when JS is disabled. drupal_set_message($this->t('The post has been added to the selected book. You may now position it relative to other pages.')); - $form_state['redirect'] = 'node/' . $this->entity->id() . '/outline'; + $form_state['redirect'] = 'node/' . $this->node->id() . '/outline'; } else { drupal_set_message($this->t('The book outline has been updated.')); @@ -122,7 +122,7 @@ public function submit(array $form, array &$form_state) { * {@inheritdoc} */ public function delete(array $form, array &$form_state) { - $form_state['redirect'] = 'node/' . $this->entity->id() . '/outline/remove'; + $form_state['redirect'] = 'node/' . $this->node->id() . '/outline/remove'; } }