diff --git a/core/modules/path/lib/Drupal/path/Controller/PathController.php b/core/modules/path/lib/Drupal/path/Controller/PathController.php
new file mode 100644
index 0000000..50a3efe
--- /dev/null
+++ b/core/modules/path/lib/Drupal/path/Controller/PathController.php
@@ -0,0 +1,171 @@
+get('database'),
+ $container->get('module_handler'),
+ $container->get('path.alias_manager')
+ );
+ }
+
+ /**
+ * Constructs a PathController object.
+ *
+ * @param \Drupal\Core\Database\Connection $database
+ * A database connection.
+ * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
+ * A module handler.
+ * @param \Drupal\Core\Path\AliasManagerInterface $alias_manager
+ * An alias manager.
+ */
+ public function __construct(Connection $database, ModuleHandlerInterface $module_handler, AliasManagerInterface $alias_manager) {
+ $this->database = $database;
+ $this->moduleHandler = $module_handler;
+ $this->aliasManager = $alias_manager;
+ }
+
+ /**
+ * The admin overview
+ *
+ * When filter key passed, perform a standard search on the given key,
+ * and return the list of matching URL aliases.
+ *
+ * @return array
+ * Returns a listing of all defined URL aliases.
+ */
+ public function adminOverview($alias = NULL) {
+ // @todo implement the session service when it lands : http://drupal.org/node/1858196
+ if (!empty($_SESSION['path_admin_filter_form'])) {
+ $alias = $_SESSION['path_admin_filter_form'];
+ }
+ // Add the filter form above the overview table.
+ $build['path_admin_filter_form'] = drupal_get_form(new PathAdminFilterForm(), $alias);
+
+ // Enable language column if language.module is enabled or if we have any
+ // alias with a language.
+ $query = $this->database->select('url_alias', 'u')
+ //->addExpression('1')
+ ->fields('u', array('pid'))
+ ->where('langcode <> :langcode', array(':langcode' => Language::LANGCODE_NOT_SPECIFIED))
+ ->range(0,1);
+ $alias_exists = (bool) $query->execute()->fetchField();
+ $multilanguage = ($this->moduleHandler->moduleExists('language') || $alias_exists);
+
+ $header = array();
+ $header[] = array('data' => t('Alias'), 'field' => 'alias', 'sort' => 'asc');
+ $header[] = array('data' => t('System'), 'field' => 'source');
+ if ($multilanguage) {
+ $header[] = array('data' => t('Language'), 'field' => 'langcode');
+ }
+ $header[] = t('Operations');
+
+ $query = $this->database->select('url_alias')
+ ->extend('Drupal\Core\Database\Query\PagerSelectExtender')
+ ->extend('Drupal\Core\Database\Query\TableSortExtender');
+ if ($alias) {
+ // Replace wildcards with PDO wildcards.
+ $query->condition('alias', '%' . preg_replace('!\*+!', '%', $alias) . '%', 'LIKE');
+ }
+ $result = $query
+ ->fields('url_alias')
+ ->orderByHeader($header)
+ ->limit(50)
+ ->execute();
+
+ $rows = array();
+ $destination = drupal_get_destination();
+ foreach ($result as $data) {
+ $row = array();
+ $row['data']['alias'] = l(Unicode::truncate($data->alias, 50, FALSE, TRUE), $data->source, array(
+ 'attributes' => array('title' => $data->alias),
+ ));
+ $row['data']['source'] = l(Unicode::truncate($data->source, 50, FALSE, TRUE), $data->source, array(
+ 'alias' => TRUE,
+ 'attributes' => array('title' => $data->source),
+ ));
+ if ($multilanguage) {
+ $row['data']['language_name'] = language_name($data->langcode);
+ }
+
+ $operations = array();
+ $operations['edit'] = array(
+ 'title' => t('edit'),
+ 'href' => "admin/config/search/path/edit/$data->pid",
+ 'query' => $destination,
+ );
+ $operations['delete'] = array(
+ 'title' => t('delete'),
+ 'href' => "admin/config/search/path/delete/$data->pid",
+ 'query' => $destination,
+ );
+ $row['data']['operations'] = array(
+ 'data' => array(
+ '#type' => 'operations',
+ '#links' => $operations,
+ ),
+ );
+
+ // If the system path maps to a different URL alias, highlight this table
+ // row to let the user know of old aliases.
+ if ($data->alias != $this->aliasManager->getPathAlias($data->source, $data->langcode)) {
+ $row['class'] = array('warning');
+ }
+
+ $rows[] = $row;
+ }
+
+ $build['path_table'] = array(
+ '#theme' => 'table',
+ '#header' => $header,
+ '#rows' => $rows,
+ '#empty' => t('No URL aliases available. Add URL alias.', array('@link' => url('admin/config/search/path/add'))),
+ );
+ $build['path_pager'] = array('#theme' => 'pager');
+
+ return $build;
+ }
+}
diff --git a/core/modules/path/lib/Drupal/path/Form/PathAdminFilterForm.php b/core/modules/path/lib/Drupal/path/Form/PathAdminFilterForm.php
new file mode 100644
index 0000000..c7fdc01
--- /dev/null
+++ b/core/modules/path/lib/Drupal/path/Form/PathAdminFilterForm.php
@@ -0,0 +1,79 @@
+ array('search-form'));
+ $form['basic'] = array('#type' => 'details',
+ '#title' => t('Filter aliases'),
+ '#attributes' => array('class' => array('container-inline')),
+ );
+ $form['basic']['filter'] = array(
+ '#type' => 'search',
+ '#title' => 'Path alias',
+ '#title_display' => 'invisible',
+ '#default_value' => $alias,
+ '#maxlength' => 128,
+ '#size' => 25,
+ );
+ $form['basic']['submit'] = array(
+ '#type' => 'submit',
+ '#value' => t('Filter'),
+ );
+ if ($alias) {
+ $form['basic']['reset'] = array(
+ '#type' => 'submit',
+ '#value' => t('Reset'),
+ );
+ }
+ return $form;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function validateForm(array &$form, array &$form_state) {
+ if ($form_state['values']['op'] == t('Filter') && empty($form_state['values']['filter'])) {
+ form_set_error('type', t('You must provide a keyword something to filter by.'));
+ }
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function submitForm(array &$form, array &$form_state) {
+ $op = $form_state['values']['op'];
+ switch ($op) {
+ case t('Filter'):
+ $_SESSION['path_admin_filter_form'] = trim($form_state['values']['filter']);
+ break;
+ case t('Reset'):
+ $_SESSION['path_admin_filter_form'] = NULL;
+ break;
+ }
+ }
+}
\ No newline at end of file
diff --git a/core/modules/path/lib/Drupal/path/Tests/PathAliasTest.php b/core/modules/path/lib/Drupal/path/Tests/PathAliasTest.php
index dbd2f41..2f57d25 100644
--- a/core/modules/path/lib/Drupal/path/Tests/PathAliasTest.php
+++ b/core/modules/path/lib/Drupal/path/Tests/PathAliasTest.php
@@ -7,6 +7,9 @@
namespace Drupal\path\Tests;
+use Drupal\Core\Database\Database;
+use Drupal\Core\Path\AliasWhitelist;
+
/**
* Tests path alias functionality.
*/
diff --git a/core/modules/path/lib/Drupal/path/Tests/PathLanguageTest.php b/core/modules/path/lib/Drupal/path/Tests/PathLanguageTest.php
index f592b72..4c26862 100644
--- a/core/modules/path/lib/Drupal/path/Tests/PathLanguageTest.php
+++ b/core/modules/path/lib/Drupal/path/Tests/PathLanguageTest.php
@@ -19,7 +19,7 @@ class PathLanguageTest extends PathTestBase {
*
* @var array
*/
- public static $modules = array('path', 'locale', 'translation');
+ public static $modules = array('path', 'language', 'translation');
public static function getInfo() {
return array(
diff --git a/core/modules/path/lib/Drupal/path/Tests/PathLanguageUiTest.php b/core/modules/path/lib/Drupal/path/Tests/PathLanguageUiTest.php
index bd0d279..e313199 100644
--- a/core/modules/path/lib/Drupal/path/Tests/PathLanguageUiTest.php
+++ b/core/modules/path/lib/Drupal/path/Tests/PathLanguageUiTest.php
@@ -17,7 +17,7 @@ class PathLanguageUiTest extends PathTestBase {
*
* @var array
*/
- public static $modules = array('path', 'locale');
+ public static $modules = array('path', 'language');
public static function getInfo() {
return array(
diff --git a/core/modules/path/path.admin.inc b/core/modules/path/path.admin.inc
index 930c1df..3020e27 100644
--- a/core/modules/path/path.admin.inc
+++ b/core/modules/path/path.admin.inc
@@ -8,94 +8,6 @@
use Drupal\Core\Language\Language;
/**
- * Returns a listing of all defined URL aliases.
- *
- * When filter key passed, perform a standard search on the given key,
- * and return the list of matching URL aliases.
- */
-function path_admin_overview($keys = NULL) {
- // Add the filter form above the overview table.
- $build['path_admin_filter_form'] = drupal_get_form('path_admin_filter_form', $keys);
- // Enable language column if language.module is enabled or if we have any
- // alias with a language.
- $alias_exists = (bool) db_query_range('SELECT 1 FROM {url_alias} WHERE langcode <> :langcode', 0, 1, array(':langcode' => Language::LANGCODE_NOT_SPECIFIED))->fetchField();
- $multilanguage = (module_exists('language') || $alias_exists);
-
- $header = array();
- $header[] = array('data' => t('Alias'), 'field' => 'alias', 'sort' => 'asc');
- $header[] = array('data' => t('System'), 'field' => 'source');
- if ($multilanguage) {
- $header[] = array('data' => t('Language'), 'field' => 'langcode');
- }
- $header[] = t('Operations');
-
- $query = db_select('url_alias')
- ->extend('Drupal\Core\Database\Query\PagerSelectExtender')
- ->extend('Drupal\Core\Database\Query\TableSortExtender');
- if ($keys) {
- // Replace wildcards with PDO wildcards.
- $query->condition('alias', '%' . preg_replace('!\*+!', '%', $keys) . '%', 'LIKE');
- }
- $result = $query
- ->fields('url_alias')
- ->orderByHeader($header)
- ->limit(50)
- ->execute();
-
- $rows = array();
- $destination = drupal_get_destination();
- foreach ($result as $data) {
- $row = array();
- $row['data']['alias'] = l(truncate_utf8($data->alias, 50, FALSE, TRUE), $data->source, array(
- 'attributes' => array('title' => $data->alias),
- ));
- $row['data']['source'] = l(truncate_utf8($data->source, 50, FALSE, TRUE), $data->source, array(
- 'alias' => TRUE,
- 'attributes' => array('title' => $data->source),
- ));
- if ($multilanguage) {
- $row['data']['language_name'] = language_name($data->langcode);
- }
-
- $operations = array();
- $operations['edit'] = array(
- 'title' => t('edit'),
- 'href' => "admin/config/search/path/edit/$data->pid",
- 'query' => $destination,
- );
- $operations['delete'] = array(
- 'title' => t('delete'),
- 'href' => "admin/config/search/path/delete/$data->pid",
- 'query' => $destination,
- );
- $row['data']['operations'] = array(
- 'data' => array(
- '#type' => 'operations',
- '#links' => $operations,
- ),
- );
-
- // If the system path maps to a different URL alias, highlight this table
- // row to let the user know of old aliases.
- if ($data->alias != drupal_container()->get('path.alias_manager')->getPathAlias($data->source, $data->langcode)) {
- $row['class'] = array('warning');
- }
-
- $rows[] = $row;
- }
-
- $build['path_table'] = array(
- '#theme' => 'table',
- '#header' => $header,
- '#rows' => $rows,
- '#empty' => t('No URL aliases available. Add URL alias.', array('@link' => url('admin/config/search/path/add'))),
- );
- $build['path_pager'] = array('#theme' => 'pager');
-
- return $build;
-}
-
-/**
* Page callback: Returns a form creating or editing a path alias.
*
* @param $path
@@ -264,57 +176,3 @@ function path_admin_form_submit($form, &$form_state) {
drupal_set_message(t('The alias has been saved.'));
$form_state['redirect'] = 'admin/config/search/path';
}
-
-/**
- * Form constructor for the path admin overview filter form.
- *
- * @ingroup forms
- * @see path_admin_filter_form_submit_filter()
- * @see path_admin_filter_form_submit_reset()
- */
-function path_admin_filter_form($form, &$form_state, $keys = '') {
- $form['#attributes'] = array('class' => array('search-form'));
- $form['basic'] = array('#type' => 'details',
- '#title' => t('Filter aliases'),
- '#attributes' => array('class' => array('container-inline')),
- );
- $form['basic']['filter'] = array(
- '#type' => 'search',
- '#title' => 'Path alias',
- '#title_display' => 'invisible',
- '#default_value' => $keys,
- '#maxlength' => 128,
- '#size' => 25,
- );
- $form['basic']['submit'] = array(
- '#type' => 'submit',
- '#value' => t('Filter'),
- '#submit' => array('path_admin_filter_form_submit_filter'),
- );
- if ($keys) {
- $form['basic']['reset'] = array(
- '#type' => 'submit',
- '#value' => t('Reset'),
- '#submit' => array('path_admin_filter_form_submit_reset'),
- );
- }
- return $form;
-}
-
-/**
- * Form submission handler for the path_admin_filter_form() Filter button.
- *
- * @see path_admin_filter_form_submit_reset()
- */
-function path_admin_filter_form_submit_filter($form, &$form_state) {
- $form_state['redirect'] = 'admin/config/search/path/list/' . trim($form_state['values']['filter']);
-}
-
-/**
- * Form submission handler for the path_admin_filter_form() Reset button.
- *
- * @see path_admin_filter_form_submit_filter()
- */
-function path_admin_filter_form_submit_reset($form, &$form_state) {
- $form_state['redirect'] = 'admin/config/search/path/list';
-}
diff --git a/core/modules/path/path.module b/core/modules/path/path.module
index 396cd25..bd74db9 100644
--- a/core/modules/path/path.module
+++ b/core/modules/path/path.module
@@ -60,10 +60,8 @@ function path_menu() {
$items['admin/config/search/path'] = array(
'title' => 'URL aliases',
'description' => "Change your site's URL paths by aliasing them.",
- 'page callback' => 'path_admin_overview',
- 'access arguments' => array('administer url aliases'),
+ 'route_name' => 'path_overview',
'weight' => -5,
- 'file' => 'path.admin.inc',
);
$items['admin/config/search/path/list'] = array(
'title' => 'List',
diff --git a/core/modules/path/path.routing.yml b/core/modules/path/path.routing.yml
index dbc6883..983600b 100644
--- a/core/modules/path/path.routing.yml
+++ b/core/modules/path/path.routing.yml
@@ -1,6 +1,13 @@
path_delete:
- pattern: 'admin/config/search/path/delete/{pid}'
+ pattern: '/admin/config/search/path/delete/{pid}'
defaults:
_form: '\Drupal\path\Form\DeleteForm'
requirements:
_permission: 'administer url aliases'
+
+path_overview:
+ pattern: '/admin/config/search/path'
+ defaults:
+ _content: '\Drupal\path\Controller\PathController::adminOverview'
+ requirements:
+ _permission: 'administer url aliases'