diff --git a/core/modules/book/book.routing.yml b/core/modules/book/book.routing.yml index 2aa7eea..413e690 100644 --- a/core/modules/book/book.routing.yml +++ b/core/modules/book/book.routing.yml @@ -34,6 +34,9 @@ book_admin_edit: defaults: _form: 'Drupal\book\Form\BookAdminEditForm' _title: 'Re-order book pages and change titles' + options: + _access_mode: 'ALL' requirements: - _book_outline_access: 'TRUE' + _permission: 'administer book outlines' + _entity_access: 'node.view' node: \d+ diff --git a/core/modules/book/book.services.yml b/core/modules/book/book.services.yml index b6980ea..e54cc62 100644 --- a/core/modules/book/book.services.yml +++ b/core/modules/book/book.services.yml @@ -2,12 +2,6 @@ services: book.manager: class: Drupal\book\BookManager arguments: ['@database', '@entity.manager'] - book.export: class: Drupal\book\BookExport arguments: ['@entity.manager'] - - access_check.book.outline: - class: Drupal\book\Access\OutlineAccessCheck - tags: - - { name: access_check } diff --git a/core/modules/book/lib/Drupal/book/Access/OutlineAccessCheck.php b/core/modules/book/lib/Drupal/book/Access/OutlineAccessCheck.php deleted file mode 100644 index 44e8fd6..0000000 --- a/core/modules/book/lib/Drupal/book/Access/OutlineAccessCheck.php +++ /dev/null @@ -1,32 +0,0 @@ -getRequirements()); - } - - /** - * {@inheritdoc} - */ - public function access(Route $route, Request $request) { - return user_access('administer book outlines') && node_access('view', $request->attributes->get('node')); - } -} diff --git a/core/modules/book/lib/Drupal/book/Form/BookAdminEditForm.php b/core/modules/book/lib/Drupal/book/Form/BookAdminEditForm.php index 86ede9f..c48fb30 100644 --- a/core/modules/book/lib/Drupal/book/Form/BookAdminEditForm.php +++ b/core/modules/book/lib/Drupal/book/Form/BookAdminEditForm.php @@ -7,20 +7,18 @@ namespace Drupal\book\Form; -use Drupal\Core\Form\FormBase; use Drupal\Component\Utility\Crypt; -use Drupal\Core\Entity\EntityInterface; +use Drupal\Core\Cache\CacheBackendInterface; use Drupal\Core\Entity\EntityStorageControllerInterface; +use Drupal\Core\Form\FormBase; use Drupal\menu_link\MenuLinkStorageControllerInterface; -use Drupal\Core\Cache\CacheBackendInterface; -use Drupal\Core\Language\Language; -use Drupal\Core\DependencyInjection\ContainerInjectionInterface; +use Drupal\node\NodeInterface; use Symfony\Component\DependencyInjection\ContainerInterface; /** * Provides a form for administering a single book's hierarchy. */ -class BookAdminEditForm extends FormBase implements ContainerInjectionInterface { +class BookAdminEditForm extends FormBase { /** * The menu cache object for this controller. @@ -48,11 +46,9 @@ class BookAdminEditForm extends FormBase implements ContainerInjectionInterface * * @param \Drupal\Core\Cache\CacheBackendInterface $cache * The menu cache object to be used by this controller. - * * @param \Drupal\Core\Entity\EntityStorageControllerInterface $node_storage * The custom block storage controller. - * - * @param \Drupal\Core\Entity\MenuLinkStorageControllerInterface $menu_link_storage + * @param \Drupal\menu_link\MenuLinkStorageControllerInterface $menu_link_storage * The custom block type storage controller. */ public function __construct(CacheBackendInterface $cache, EntityStorageControllerInterface $node_storage, MenuLinkStorageControllerInterface $menu_link_storage) { @@ -83,7 +79,7 @@ public function getFormID() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state, EntityInterface $node = NULL) { + public function buildForm(array $form, array &$form_state, NodeInterface $node = NULL) { $form['#title'] = $node->label(); $form['#node'] = $node; $this->bookAdminTable($node, $form); @@ -132,14 +128,12 @@ public function submitForm(array &$form, array &$form_state) { // Update the title if changed. if ($row['title']['#default_value'] != $values['title']) { $node = $this->nodeStorage->load($values['nid']); - $langcode = Language::LANGCODE_NOT_SPECIFIED; + $node->log = $this->t('Title changed from %original to %current.', array('%original' => $node->label(), '%current' => $values['title'])); $node->title = $values['title']; $node->book['link_title'] = $values['title']; $node->setNewRevision(); - $node->log = $this->t('Title changed from %original to %current.', array('%original' => $node->title, '%current' => $values['title'])); - $node->save(); - watchdog('content', 'book: updated %title.', array('%title' => $node->label()), WATCHDOG_NOTICE, l($this->t('view'), 'node/' . $node->nid)); + watchdog('content', 'book: updated %title.', array('%title' => $node->label()), WATCHDOG_NOTICE, l($this->t('view'), 'node/' . $node->id())); } } } @@ -156,14 +150,14 @@ public function submitForm(array &$form, array &$form_state) { /** * Builds the table portion of the form for the book administration page. * - * @param \Drupal\Core\Entity\EntityInterface $node + * @param \Drupal\node\NodeInterface $node * The node of the top-level page in the book. - * @param $form + * @param array $form * The form that is being modified, passed by reference. * - * @see \Drupal\book\Form\BookAdminEditForm::buildForm() + * @see self::buildForm() */ - protected function bookAdminTable(EntityInterface $node, &$form) { + protected function bookAdminTable(NodeInterface $node, array &$form) { $form['table'] = array( '#theme' => 'book_admin_table', '#tree' => TRUE, @@ -191,17 +185,14 @@ protected function bookAdminTable(EntityInterface $node, &$form) { /** * Helps build the main table in the book administration page form. * - * @param $tree + * @param array $tree * A subtree of the book menu hierarchy. - * @param $form + * @param array $form * The form that is being modified, passed by reference. * - * @return - * The modified form array. - * - * @see \Drupal\book\Form\BookAdminEditForm::buildForm() + * @see self::buildForm() */ - protected function bookAdminTableTree($tree, &$form) { + protected function bookAdminTableTree(array $tree, array &$form) { // The delta must be big enough to give each node a distinct value. $count = count($tree); $delta = ($count < 30) ? 15 : intval($count / 2) + 1; @@ -238,8 +229,6 @@ protected function bookAdminTableTree($tree, &$form) { $this->bookAdminTableTree($data['below'], $form); } } - - return $form; } }