diff --git a/core/includes/menu.inc b/core/includes/menu.inc index 6209fac..cd8121d 100644 --- a/core/includes/menu.inc +++ b/core/includes/menu.inc @@ -2723,25 +2723,6 @@ function menu_router_build($save = FALSE) { $router_items = call_user_func($module . '_menu'); if (isset($router_items) && is_array($router_items)) { foreach (array_keys($router_items) as $path) { - // If the menu item is a default local task and incorrectly references a - // route, remove it. - // @todo This may be removed later depending on the outcome of - // http://drupal.org/node/1889790 - if (isset($router_items[$path]['type']) && $router_items[$path]['type'] == MENU_DEFAULT_LOCAL_TASK) { - unset($router_items[$path]['route_name']); - } - // If the menu item references a route, normalize the route information - // into the old structure. Note that routes are keyed by name, not path, - // so the path of the route takes precedence. - if (isset($router_items[$path]['route_name'])) { - $router_item = $router_items[$path]; - $router_item['page callback'] = 'USES_ROUTE'; - $router_item['access callback'] = TRUE; - $new_path = _menu_router_translate_route($router_item['route_name']); - unset($router_items[$path]); - $router_items[$new_path] = $router_item; - $path = $new_path; - } $router_items[$path]['module'] = $module; } $callbacks = array_merge($callbacks, $router_items); @@ -2749,6 +2730,26 @@ function menu_router_build($save = FALSE) { } // Alter the menu as defined in modules, keys are like user/%user. drupal_alter('menu', $callbacks); + foreach ($callbacks as $path => $router_item) { + // If the menu item is a default local task and incorrectly references a + // route, remove it. + // @todo This may be removed later depending on the outcome of + // http://drupal.org/node/1889790 + if (isset($router_item['type']) && $router_item['type'] == MENU_DEFAULT_LOCAL_TASK) { + unset($callbacks[$path]['route_name']); + } + // If the menu item references a route, normalize the route information + // into the old structure. Note that routes are keyed by name, not path, + // so the path of the route takes precedence. + if (isset($router_item['route_name'])) { + $router_item['page callback'] = 'USES_ROUTE'; + $router_item['access callback'] = TRUE; + $new_path = _menu_router_translate_route($router_item['route_name']); + + unset($callbacks[$path]); + $callbacks[$new_path] = $router_item; + } + } list($menu, $masks) = _menu_router_build($callbacks, $save); _menu_router_cache($menu); diff --git a/core/modules/node/lib/Drupal/node/Plugin/views/field/NodeBulkForm.php b/core/modules/node/lib/Drupal/node/Plugin/views/field/NodeBulkForm.php index be18eef..da633d7 100644 --- a/core/modules/node/lib/Drupal/node/Plugin/views/field/NodeBulkForm.php +++ b/core/modules/node/lib/Drupal/node/Plugin/views/field/NodeBulkForm.php @@ -10,6 +10,7 @@ use Drupal\Component\Annotation\PluginID; use Drupal\system\Plugin\views\field\BulkFormBase; use Drupal\Core\Cache\Cache; +use Drupal\Core\Entity\EntityManager; /** * Defines a node operations bulk form element. @@ -19,22 +20,31 @@ class NodeBulkForm extends BulkFormBase { /** + * Constructs a new NodeBulkForm object. + */ + public function __construct(array $configuration, $plugin_id, array $plugin_definition, EntityManager $manager) { + parent::__construct($configuration, $plugin_id, $plugin_definition, $manager); + + // Filter the actions to only include those for the 'node' entity type. + $this->actions = array_filter($this->actions, function ($action) { + return $action->getType() == 'node'; + }); + } + + /** * {@inheritdoc} */ protected function getBulkOptions() { - module_load_include('admin.inc', 'node'); - return array_map(function($operation) { - return $operation['label']; - }, \Drupal::moduleHandler()->invokeAll('node_operations')); + return array_map(function ($action) { + return $action->label(); + }, $this->actions); } /** * {@inheritdoc} */ public function views_form_validate(&$form, &$form_state) { - if (isset($form_state['values'][$this->options['id']])) { - $selected = array_filter($form_state['values'][$this->options['id']]); - } + $selected = array_filter($form_state['values'][$this->options['id']]); if (empty($selected)) { form_set_error('', t('No items selected.')); } @@ -44,33 +54,9 @@ public function views_form_validate(&$form, &$form_state) { * {@inheritdoc} */ public function views_form_submit(&$form, &$form_state) { - form_load_include($form_state, 'admin.inc', 'node'); + parent::views_form_submit($form, $form_state); if ($form_state['step'] == 'views_form_views_form') { - // Filter only selected checkboxes. - $selected = array_filter($form_state['values'][$this->options['id']]); - $nodes = array(); - foreach (array_intersect_key($this->view->result, $selected) as $row) { - $node = $this->get_entity($row); - $nodes[$node->id()] = $node; - } - - $operations = \Drupal::moduleHandler()->invokeAll('node_operations'); - $operation = $operations[$form_state['values']['action']]; - // Filter out unchecked nodes - $nodes = array_filter($nodes); - // Add in callback arguments if present. - if (isset($operation['callback arguments'])) { - $args = array_merge(array($nodes), $operation['callback arguments']); - } - else { - $args = array($nodes); - } - call_user_func_array($operation['callback'], $args); Cache::invalidateTags(array('content' => TRUE)); - - if (isset($operation['redirect'])) { - $form_state['redirect'] = $operation['redirect']; - } } } diff --git a/core/modules/system/lib/Drupal/system/Plugin/views/field/BulkFormBase.php b/core/modules/system/lib/Drupal/system/Plugin/views/field/BulkFormBase.php index 348085c..4bc26dd 100644 --- a/core/modules/system/lib/Drupal/system/Plugin/views/field/BulkFormBase.php +++ b/core/modules/system/lib/Drupal/system/Plugin/views/field/BulkFormBase.php @@ -152,7 +152,7 @@ public function views_form_submit(&$form, &$form_state) { $operation_definition = $action->getPluginDefinition(); if (!empty($operation_definition['confirm_form_path'])) { - $form_state['confirm_form_path'] = $operation_definition['confirm_form_path']; + $form_state['redirect'] = $operation_definition['confirm_form_path']; } } } diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/display/PathPluginBase.php b/core/modules/views/lib/Drupal/views/Plugin/views/display/PathPluginBase.php index bb05080..adb6a89 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/views/display/PathPluginBase.php +++ b/core/modules/views/lib/Drupal/views/Plugin/views/display/PathPluginBase.php @@ -27,6 +27,33 @@ public function hasPath() { } /** + * {@inheritdoc} + */ + public function getPath() { + $bits = explode('/', $this->getOption('path')); + $bits = $this->processDefaultPath($bits); + return implode('/', $bits); + } + + /** + * Processes the bits of a path to handle default tabs. + * + * @param array $bits + * An array of path parts. + */ + protected function processDefaultPath($bits) { + $menu = $this->getOption('menu'); + $tab_options = $this->getOption('tab_options'); + if ($menu['type'] == 'default tab' && !empty($tab_options['type']) && $tab_options['type'] != 'none') { + $bit = array_pop($bits); + if ($bit == '%views_arg' || empty($bits)) { + $bits[] = $bit; + } + } + return $bits; + } + + /** * Overrides \Drupal\views\Plugin\views\display\DisplayPluginBase:defineOptions(). */ protected function defineOptions() { @@ -84,6 +111,9 @@ public function collectRoutes(RouteCollection $collection) { $bits[] = $bit; } + // If this is to be a default tab, create the route for the parent path. + $bits = $this->processDefaultPath($bits); + $route_path = '/' . implode('/', $bits); $route = new Route($route_path, $defaults); @@ -182,6 +212,10 @@ public function executeHookMenu($callbacks) { // we can't do this if they tried to make the last path bit variable. // @todo: We can validate this. if ($bit != '%views_arg' && !empty($bits)) { + // Assign the route name to the parent route, not the default tab. + $default_route_name = $items[$path]['route_name']; + unset($items[$path]['route_name']); + $default_path = implode('/', $bits); $items[$default_path] = array( // Default views page entry. @@ -191,6 +225,7 @@ public function executeHookMenu($callbacks) { 'title' => $tab_options['title'], 'description' => $tab_options['description'], 'menu_name' => $tab_options['name'], + 'route_name' => $default_route_name, ); switch ($tab_options['type']) { default: