diff --git a/core/lib/Drupal/Core/Path/AliasManager.php b/core/lib/Drupal/Core/Path/AliasManager.php
index 72e5707..9955946 100644
--- a/core/lib/Drupal/Core/Path/AliasManager.php
+++ b/core/lib/Drupal/Core/Path/AliasManager.php
@@ -312,4 +312,20 @@ protected function pathAliasWhitelistRebuild($source = NULL) {
}
$this->whitelist->clear();
}
+ /**
+ * Checks if a path alias exists.
+ *
+ * @return bool
+ */
+ public function checkAliasExists($pid, $alias, $langcode) {
+ $query = $this->connection->select('url_alias', 'u')
+ ->fields('u', array('pid'))
+ ->where('pid <> :pid AND alias = :alias AND langcode = :langcode', array(
+ ':pid' => $pid,
+ ':alias' => $alias,
+ ':langcode' => $langcode))
+ ->range(0,1);
+ return (bool) $query->execute()->fetchField();
+ }
+
}
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..2301317
--- /dev/null
+++ b/core/modules/path/lib/Drupal/path/Controller/PathController.php
@@ -0,0 +1,153 @@
+connection = $connection;
+ $this->aliasManager = $alias_manager;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public static function create(ContainerInterface $container) {
+ return new static(
+ $container->get('database'),
+ $container->get('path.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: 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->connection->select('url_alias', 'u')
+ ->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' => $this->t('Alias'), 'field' => 'alias', 'sort' => 'asc');
+ $header[] = array('data' => $this->t('System'), 'field' => 'source');
+ if ($multilanguage) {
+ $header[] = array('data' => $this->t('Language'), 'field' => 'langcode');
+ }
+ $header[] = $this->t('Operations');
+
+ $query = $this->connection->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' => $this->t('edit'),
+ 'href' => "admin/config/search/path/edit/$data->pid",
+ 'query' => $destination,
+ );
+ $operations['delete'] = array(
+ 'title' => $this->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' => $this->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/EditForm.php b/core/modules/path/lib/Drupal/path/Form/EditForm.php
new file mode 100644
index 0000000..efd1c16
--- /dev/null
+++ b/core/modules/path/lib/Drupal/path/Form/EditForm.php
@@ -0,0 +1,208 @@
+path = $path;
+ $this->moduleHandler = $module_handler;
+ $this->aliasManager = $alias_manager;
+ }
+
+ /**
+ * {{@inheritdoc}}
+ */
+ public static function create(ContainerInterface $container) {
+ return new static(
+ $container->get('path.crud'),
+ $container->get('module_handler'),
+ $container->get('path.alias.manager')
+ );
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getFormID() {
+ return 'path_alias_edit';
+ }
+
+ /**
+ * {@inheritdoc}
+ * @param int $pid
+ * an alias id for editing or NULL to add a new one.
+ */
+ public function buildForm(array $form, array &$form_state, $pid = NULL) {
+
+ $pathAlias = $this->path->load(array('pid' => $pid));
+ drupal_set_title($pathAlias['alias']);
+
+ $form['source'] = array(
+ '#type' => 'textfield',
+ '#title' => $this->t('Existing system path'),
+ '#default_value' => $pathAlias['source'],
+ '#maxlength' => 255,
+ '#size' => 45,
+ '#description' => $this->t('Specify the existing path you wish to alias. For example: node/28, forum/1, taxonomy/term/1.'),
+ '#field_prefix' => url(NULL, array('absolute' => TRUE)),
+ '#required' => TRUE,
+ );
+ $form['alias'] = array(
+ '#type' => 'textfield',
+ '#title' => $this->t('Path alias'),
+ '#default_value' => $pathAlias['alias'],
+ '#maxlength' => 255,
+ '#size' => 45,
+ '#description' => $this->t('Specify an alternative path by which this data can be accessed. For example, type "about" when writing an about page. Use a relative path and don\'t add a trailing slash or the URL alias won\'t work.'),
+ '#field_prefix' => url(NULL, array('absolute' => TRUE)),
+ '#required' => TRUE,
+ );
+
+ // A hidden value unless language.module is enabled.
+ if ($this->moduleHandler->moduleExists('language')) {
+ // @todo add DI for language_list
+ $languages = language_list();
+ $language_options = array();
+ foreach ($languages as $langcode => $language) {
+ $language_options[$langcode] = $language->name;
+ }
+
+ $form['langcode'] = array(
+ '#type' => 'select',
+ '#title' => $this->t('Language'),
+ '#options' => $language_options,
+ '#empty_value' => Language::LANGCODE_NOT_SPECIFIED,
+ '#empty_option' => $this->t('- None -'),
+ '#default_value' => $pathAlias['langcode'],
+ '#weight' => -10,
+ '#description' => $this->t('A path alias set for a specific language will always be used when displaying this page in that language, and takes precedence over path aliases set as - None -.'),
+ );
+ }
+ else {
+ $form['langcode'] = array(
+ '#type' => 'value',
+ '#value' => $pathAlias['langcode']
+ );
+ }
+
+ $form['actions'] = array('#type' => 'actions');
+ $form['actions']['submit'] = array(
+ '#type' => 'submit',
+ '#value' => $this->t('Save'),
+ );
+ if ($pathAlias['pid']) {
+ $form['pid'] = array(
+ '#type' => 'hidden',
+ '#value' => $pathAlias['pid'],
+ );
+ $form['actions']['delete'] = array(
+ '#type' => 'submit',
+ '#submit' => array(array($this, 'deleteForm')),
+ '#value' => $this->t('Delete'),
+ );
+ }
+
+ return $form;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function validateForm(array &$form, array &$form_state) {
+ $pid = isset($form_state['values']['pid']) ? $form_state['values']['pid'] : 0;
+ $alias = $form_state['values']['alias'];
+ // Language is only set if language.module is enabled, otherwise save for all
+ // languages.
+ $langcode = isset($form_state['values']['langcode']) ? $form_state['values']['langcode'] : Language::LANGCODE_NOT_SPECIFIED;
+ $source = &$form_state['values']['source'];
+ $source = $this->aliasManager->getSystemPath($source, $langcode);
+
+ $alias_exists = $aliasManager->checkAliasExists($pid, $alias, $langcode);
+ if ($alias_exists) {
+ form_set_error('alias', $this->t('The alias %alias is already in use in this language.', array('%alias' => $alias)));
+ }
+ if (!drupal_valid_path($source)) {
+ form_set_error('source', $this->t("The path '@link_path' is either invalid or you do not have access to it.", array('@link_path' => $source)));
+ }
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function submitForm(array &$form, array &$form_state) {
+ // Remove unnecessary values.
+ form_state_values_clean($form_state);
+
+ $pid = isset($form_state['values']['pid']) ? $form_state['values']['pid'] : NULL;
+ $alias = $form_state['values']['alias'];
+ // Language is only set if language.module is enabled, otherwise save for all
+ // languages.
+ $langcode = isset($form_state['values']['langcode']) ? $form_state['values']['langcode'] : Language::LANGCODE_NOT_SPECIFIED;
+ $source = &$form_state['values']['source'];
+ $source = $this->aliasManager->getSystemPath($source, $langcode);
+ $this->path->save($source, $alias, $langcode, $pid);
+ drupal_set_message(t('The alias has been saved.'));
+ $form_state['redirect'] = 'admin/config/search/path';
+ }
+ /**
+ * {@inheritdoc}
+ */
+ public function deleteForm(array &$form, array &$form_state) {
+ // Remove unnecessary values.
+ form_state_values_clean($form_state);
+
+ $pid = isset($form_state['values']['pid']) ? $form_state['values']['pid'] : NULL;
+ $alias = $form_state['values']['alias'];
+ // Language is only set if language.module is enabled, otherwise save for all
+ // languages.
+ $langcode = isset($form_state['values']['langcode']) ? $form_state['values']['langcode'] : Language::LANGCODE_NOT_SPECIFIED;
+ $source = &$form_state['values']['source'];
+ $source = $this->aliasManager->getSystemPath($source, $langcode);
+ $destination = array();
+ if (isset($_GET['destination'])) {
+ $destination = drupal_get_destination();
+ unset($_GET['destination']);
+ }
+ $form_state['redirect'] = array('admin/config/search/path/delete/' . $pid, array('query' => $destination));
+ }
+}
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..c8e1761
--- /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;
+ }
+ }
+}
diff --git a/core/modules/path/lib/Drupal/path/Tests/PathAliasTest.php b/core/modules/path/lib/Drupal/path/Tests/PathAliasTest.php
index 87ca4be..89d82a7 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 1724a4a..d527cf9 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
deleted file mode 100644
index b03f8d6..0000000
--- a/core/modules/path/path.admin.inc
+++ /dev/null
@@ -1,321 +0,0 @@
- :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::service('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
- * An array containing the path ID, source, alias, and language code.
- *
- * @return
- * A form for adding or editing a URL alias.
- *
- * @see path_menu()
- */
-function path_admin_edit($path = array()) {
- if ($path) {
- drupal_set_title($path['alias']);
- $output = drupal_get_form('path_admin_form', $path);
- }
- else {
- $output = drupal_get_form('path_admin_form');
- }
-
- return $output;
-}
-
-/**
- * Form constructor for the path administration form.
- *
- * @param $path
- * An array containing the path ID, source, alias, and language code.
- *
- * @ingroup forms
- * @see path_admin_form_validate()
- * @see path_admin_form_submit()
- * @see path_admin_form_delete_submit()
- */
-function path_admin_form($form, &$form_state, $path = array('source' => '', 'alias' => '', 'langcode' => Language::LANGCODE_NOT_SPECIFIED, 'pid' => NULL)) {
- $form['source'] = array(
- '#type' => 'textfield',
- '#title' => t('Existing system path'),
- '#default_value' => $path['source'],
- '#maxlength' => 255,
- '#size' => 45,
- '#description' => t('Specify the existing path you wish to alias. For example: node/28, forum/1, taxonomy/term/1.'),
- '#field_prefix' => url(NULL, array('absolute' => TRUE)),
- '#required' => TRUE,
- );
- $form['alias'] = array(
- '#type' => 'textfield',
- '#title' => t('Path alias'),
- '#default_value' => $path['alias'],
- '#maxlength' => 255,
- '#size' => 45,
- '#description' => t('Specify an alternative path by which this data can be accessed. For example, type "about" when writing an about page. Use a relative path and don\'t add a trailing slash or the URL alias won\'t work.'),
- '#field_prefix' => url(NULL, array('absolute' => TRUE)),
- '#required' => TRUE,
- );
-
- // A hidden value unless language.module is enabled.
- if (module_exists('language')) {
- $languages = language_list();
- foreach ($languages as $langcode => $language) {
- $language_options[$langcode] = $language->name;
- }
-
- $form['langcode'] = array(
- '#type' => 'select',
- '#title' => t('Language'),
- '#options' => $language_options,
- '#empty_value' => Language::LANGCODE_NOT_SPECIFIED,
- '#empty_option' => t('- None -'),
- '#default_value' => $path['langcode'],
- '#weight' => -10,
- '#description' => t('A path alias set for a specific language will always be used when displaying this page in that language, and takes precedence over path aliases set as - None -.'),
- );
- }
- else {
- $form['langcode'] = array(
- '#type' => 'value',
- '#value' => $path['langcode']
- );
- }
-
- $form['actions'] = array('#type' => 'actions');
- $form['actions']['submit'] = array(
- '#type' => 'submit',
- '#value' => t('Save'),
- );
- if ($path['pid']) {
- $form['pid'] = array(
- '#type' => 'hidden',
- '#value' => $path['pid'],
- );
- $form['actions']['delete'] = array(
- '#type' => 'submit',
- '#value' => t('Delete'),
- '#submit' => array('path_admin_form_delete_submit'),
- );
- }
-
- return $form;
-}
-
-/**
- * Form submission handler for the 'Delete' button on path_admin_form().
- *
- * @see path_admin_form_validate()
- * @see path_admin_form_submit()
- */
-function path_admin_form_delete_submit($form, &$form_state) {
- $destination = array();
- $query = Drupal::request()->query;
- if ($query->has('destination')) {
- $destination = drupal_get_destination();
- $query->remove('destination');
- }
- $form_state['redirect'] = array('admin/config/search/path/delete/' . $form_state['values']['pid'], array('query' => $destination));
-}
-
-/**
- * Form validation handler for path_admin_form().
- *
- * @see path_admin_form_submit()
- * @see path_admin_form_delete_submit()
- */
-function path_admin_form_validate($form, &$form_state) {
- $source = &$form_state['values']['source'];
- $source = Drupal::service('path.alias_manager')->getSystemPath($source);
- $alias = $form_state['values']['alias'];
- $pid = isset($form_state['values']['pid']) ? $form_state['values']['pid'] : 0;
- // Language is only set if language.module is enabled, otherwise save for all
- // languages.
- $langcode = isset($form_state['values']['langcode']) ? $form_state['values']['langcode'] : Language::LANGCODE_NOT_SPECIFIED;
-
- $has_alias = db_query("SELECT COUNT(alias) FROM {url_alias} WHERE pid <> :pid AND alias = :alias AND langcode = :langcode", array(
- ':pid' => $pid,
- ':alias' => $alias,
- ':langcode' => $langcode,
- ))
- ->fetchField();
-
- if ($has_alias) {
- form_set_error('alias', t('The alias %alias is already in use in this language.', array('%alias' => $alias)));
- }
- if (!drupal_valid_path($source)) {
- form_set_error('source', t("The path '@link_path' is either invalid or you do not have access to it.", array('@link_path' => $source)));
- }
-}
-
-/**
- * Form submission handler for path_admin_form().
- *
- * @see path_admin_form_validate()
- * @see path_admin_form_delete_submit()
- */
-function path_admin_form_submit($form, &$form_state) {
- // Remove unnecessary values.
- form_state_values_clean($form_state);
-
- $pid = isset($form_state['values']['pid']) ? $form_state['values']['pid'] : 0;
- $source = &$form_state['values']['source'];
- $source = Drupal::service('path.alias_manager')->getSystemPath($source);
- $alias = $form_state['values']['alias'];
- // Language is only set if language.module is enabled, otherwise save for all
- // languages.
- $langcode = isset($form_state['values']['langcode']) ? $form_state['values']['langcode'] : Language::LANGCODE_NOT_SPECIFIED;
-
- Drupal::service('path.crud')->save($source, $alias, $langcode, $pid);
-
- 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.local_action.yml b/core/modules/path/path.local_action.yml
new file mode 100644
index 0000000..ecba426
--- /dev/null
+++ b/core/modules/path/path.local_action.yml
@@ -0,0 +1,5 @@
+path_add:
+ route_name: path_add
+ title: 'Add alias'
+ appears_on:
+ - path_overview
diff --git a/core/modules/path/path.module b/core/modules/path/path.module
index e6a1063..fcdf5e8 100644
--- a/core/modules/path/path.module
+++ b/core/modules/path/path.module
@@ -58,32 +58,26 @@ 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',
'type' => MENU_DEFAULT_LOCAL_TASK,
);
- $items['admin/config/search/path/edit/%path'] = array(
+ // @todo add a paramconverter for path ?
+ $items['admin/config/search/path/edit/%'] = array(
'title' => 'Edit alias',
- 'page callback' => 'path_admin_edit',
- 'page arguments' => array(5),
- 'access arguments' => array('administer url aliases'),
- 'file' => 'path.admin.inc',
+ 'route_name' => 'path_edit',
);
- $items['admin/config/search/path/delete/%path'] = array(
+ $items['admin/config/search/path/delete/%'] = array(
'title' => 'Delete alias',
'route_name' => 'path_delete',
);
$items['admin/config/search/path/add'] = array(
- 'title' => 'Add alias',
- 'page callback' => 'path_admin_edit',
- 'access arguments' => array('administer url aliases'),
- 'type' => MENU_LOCAL_ACTION,
- 'file' => 'path.admin.inc',
+ 'route_name' => 'path_add',
+ 'type' => MENU_SIBLING_LOCAL_TASK,
+ 'weight' => 1,
);
return $items;
diff --git a/core/modules/path/path.routing.yml b/core/modules/path/path.routing.yml
index dbc6883..a323a45 100644
--- a/core/modules/path/path.routing.yml
+++ b/core/modules/path/path.routing.yml
@@ -1,5 +1,26 @@
+path_overview:
+ pattern: '/admin/config/search/path'
+ defaults:
+ _content: '\Drupal\path\Controller\PathController::adminOverview'
+ requirements:
+ _permission: 'administer url aliases'
+
+path_add:
+ pattern: '/admin/config/search/path/add'
+ defaults:
+ _form: '\Drupal\path\Form\EditForm'
+ requirements:
+ _permission: 'administer url aliases'
+
+path_edit:
+ pattern: '/admin/config/search/path/edit/{pid}'
+ defaults:
+ _form: '\Drupal\path\Form\EditForm'
+ requirements:
+ _permission: 'administer url aliases'
+
path_delete:
- pattern: 'admin/config/search/path/delete/{pid}'
+ pattern: '/admin/config/search/path/delete/{pid}'
defaults:
_form: '\Drupal\path\Form\DeleteForm'
requirements: