diff --git a/core/modules/book/lib/Drupal/book/Access/OutlineAccessCheck.php b/core/modules/book/lib/Drupal/book/Access/OutlineAccessCheck.php index 92eef11..2cd4903 100644 --- a/core/modules/book/lib/Drupal/book/Access/OutlineAccessCheck.php +++ b/core/modules/book/lib/Drupal/book/Access/OutlineAccessCheck.php @@ -27,6 +27,6 @@ public function applies(Route $route) { * Implements AccessCheckInterface::access(). */ public function access(Route $route, Request $request) { - return user_access('administer book outlines') && node_access('view', $request->get('node')); + 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 7322d09..8466153 100644 --- a/core/modules/book/lib/Drupal/book/Form/BookAdminEditForm.php +++ b/core/modules/book/lib/Drupal/book/Form/BookAdminEditForm.php @@ -9,11 +9,38 @@ use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Form\FormInterface; +use Drupal\Core\ControllerInterface; +use Drupal\Core\Cache\CacheBackendInterface; +use Symfony\Component\DependencyInjection\ContainerInterface; /** * Provides a form for administering a single book's hierarchy. */ -class BookAdminEditForm implements FormInterface { +class BookAdminEditForm implements FormInterface, ControllerInterface { + + /** + * The menu cache object for this controller. + * + * @var \Drupal\Core\Cache\CacheBackendInterface + */ + protected $cache; + + /** + * Constructs a new BookAdminEditForm. + * + * @param \Drupal\Core\Cache\CacheBackendInterface $cache + * The menu cache object to be used by this controller. + */ + public function __construct(CacheBackendInterface $cache) { + $this->cache = $cache; + } + + /** + * Implements \Drupal\Core\ControllerInterface::create(). + */ + public static function create(ContainerInterface $container) { + return new static($container->get('cache.menu')); + } /** * Implements \Drupal\Core\Form\FormInterface::getFormID(). @@ -33,7 +60,7 @@ public function getFormID() { public function buildForm(array $form, array &$form_state, EntityInterface $node = NULL) { drupal_set_title($node->label()); $form['#node'] = $node; - $this->book_admin_table($node, $form); + $this->bookAdminTable($node, $form); $form['save'] = array( '#type' => 'submit', '#value' => t('Save book pages'), @@ -101,7 +128,7 @@ public function submitForm(array &$form, array &$form_state) { // Flush static and cache. drupal_static_reset('book_menu_subtree_data'); $cid = 'links:' . $form['#node']->book['menu_name'] . ':subtree-cid:' . $form['#node']->book['mlid']; - cache('menu')->delete($cid); + $this->cache->delete($cid); } drupal_set_message(t('Updated book %title.', array('%title' => $form['#node']->label()))); @@ -117,7 +144,7 @@ public function submitForm(array &$form, array &$form_state) { * * @see book_admin_edit() */ - private function book_admin_table(EntityInterface $node, &$form) { + protected function bookAdminTable(EntityInterface $node, &$form) { $form['table'] = array( '#theme' => 'book_admin_table', '#tree' => TRUE, @@ -137,7 +164,7 @@ private function book_admin_table(EntityInterface $node, &$form) { '#type' => 'value', '#value' => $hash, ); - $this->book_admin_table_tree($tree['below'], $form['table']); + $this->bookAdminTableTree($tree['below'], $form['table']); } } @@ -154,7 +181,7 @@ private function book_admin_table(EntityInterface $node, &$form) { * * @see book_admin_edit() */ - private function book_admin_table_tree($tree, &$form) { + protected function bookAdminTableTree($tree, &$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; @@ -188,7 +215,7 @@ private function book_admin_table_tree($tree, &$form) { ), ); if ($data['below']) { - $this->book_admin_table_tree($data['below'], $form); + $this->bookAdminTableTree($data['below'], $form); } }