diff --git a/pathauto.links.task.yml b/pathauto.links.task.yml index d6fa0bc..1dc24dc 100644 --- a/pathauto.links.task.yml +++ b/pathauto.links.task.yml @@ -1,23 +1,23 @@ pathauto.patterns.form: route_name: entity.pathauto_pattern.collection - base_route: path.admin_overview + base_route: entity.path_alias.collection title: 'Patterns' weight: 10 pathauto.settings.form: route_name: pathauto.settings.form - base_route: path.admin_overview + base_route: entity.path_alias.collection title: 'Settings' weight: 20 pathauto.bulk.update.form: route_name: pathauto.bulk.update.form - base_route: path.admin_overview + base_route: entity.path_alias.collection title: 'Bulk generate' weight: 30 pathauto.admin.delete: route_name: pathauto.admin.delete - base_route: path.admin_overview + base_route: entity.path_alias.collection title: 'Delete aliases' weight: 40 diff --git a/pathauto.module b/pathauto.module index c441c6d..876f071 100644 --- a/pathauto.module +++ b/pathauto.module @@ -172,3 +172,16 @@ function pathauto_pattern_validate($element, FormStateInterface $form_state) { return $element; } + +/** + * Implements hook_local_tasks_alter(). + */ +function pathauto_local_tasks_alter(&$local_tasks) { + if (version_compare(\Drupal::VERSION, '8.8', '<')) { + foreach ($local_tasks as &$local_task) { + if ($local_task['provider'] === 'pathauto') { + $local_task['base_route'] = 'path.admin_overview'; + } + } + } +} diff --git a/tests/src/Unit/Menu/PathautoLocalTasksTest.php b/tests/src/Unit/Menu/PathautoLocalTasksTest.php new file mode 100644 index 0000000..33723f1 --- /dev/null +++ b/tests/src/Unit/Menu/PathautoLocalTasksTest.php @@ -0,0 +1,52 @@ +directoryList = [ + 'path' => 'core/modules/path', + 'pathauto' => 'modules/pathauto', + ]; + parent::setUp(); + } + + /** + * Tests pathauto local tasks existence. + * + * @dataProvider getPathautoAdminRoutes + */ + public function testPathautoAdminLocalTasks($route) { + $this->assertLocalTasks($route, [ + 0 => [ + 'entity.path_alias.collection', + 'pathauto.patterns.form', + 'pathauto.settings.form', + 'pathauto.bulk.update.form', + 'pathauto.admin.delete', + ], + ]); + } + + /** + * Provides a list of routes to test. + */ + public function getPathautoAdminRoutes() { + return [ + ['entity.path_alias.collection'], + ['entity.pathauto_pattern.collection'], + ['pathauto.settings.form'], + ['pathauto.bulk.update.form'], + ['pathauto.admin.delete'], + ]; + } + +}