diff --git a/core/modules/path/lib/Drupal/path/Controller/PathController.php b/core/modules/path/lib/Drupal/path/Controller/PathController.php index d70c25d..ac7399e 100644 --- a/core/modules/path/lib/Drupal/path/Controller/PathController.php +++ b/core/modules/path/lib/Drupal/path/Controller/PathController.php @@ -93,8 +93,8 @@ public function adminOverview($alias = NULL) { $header[] = $this->t('Operations'); $query = $this->connection->select('url_alias') - ->extend('PagerSelectExtender') - ->extend('TableSortExtender'); + ->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'); diff --git a/core/modules/path/lib/Drupal/path/Form/EditForm.php b/core/modules/path/lib/Drupal/path/Form/EditForm.php index 1520dda..471fcb2 100644 --- a/core/modules/path/lib/Drupal/path/Form/EditForm.php +++ b/core/modules/path/lib/Drupal/path/Form/EditForm.php @@ -23,7 +23,7 @@ class EditForm extends FormBase { /** * The path crud service. * - * @var Path $path + * @var \Drupal\Core\Path\Path; */ protected $path; @@ -51,6 +51,14 @@ class EditForm extends FormBase { /** * Constructs a \Drupal\Core\Form\FormBase object. * + * @param \Drupal\Core\Path\Path $path + * The path crud service. + * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler + * The module handler service. + * @param \Drupal\Core\Path\AliasManagerInterface $alias_manager + * The path alias manager service. + * @param \Drupal\Core\Routing\UrlGeneratorInterface $url_generator + * The URL generator service. */ public function __construct(Path $path, ModuleHandlerInterface $module_handler, AliasManagerInterface $alias_manager, UrlGeneratorInterface $url_generator) { $this->path = $path; @@ -84,14 +92,12 @@ public function getFormID() { * 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)); - $form['#title'] = $pathAlias['alias']; - + $path_alias = $this->path->load(array('pid' => $pid)); + $form['#title'] = $path_alias['alias']; $form['source'] = array( '#type' => 'textfield', '#title' => $this->t('Existing system path'), - '#default_value' => $pathAlias['source'], + '#default_value' => $path_alias['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.'), @@ -101,7 +107,7 @@ public function buildForm(array $form, array &$form_state, $pid = NULL) { $form['alias'] = array( '#type' => 'textfield', '#title' => $this->t('Path alias'), - '#default_value' => $pathAlias['alias'], + '#default_value' => $path_alias['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.'), @@ -124,7 +130,7 @@ public function buildForm(array $form, array &$form_state, $pid = NULL) { '#options' => $language_options, '#empty_value' => Language::LANGCODE_NOT_SPECIFIED, '#empty_option' => $this->t('- None -'), - '#default_value' => $pathAlias['langcode'], + '#default_value' => $path_alias['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 -.'), ); @@ -132,7 +138,7 @@ public function buildForm(array $form, array &$form_state, $pid = NULL) { else { $form['langcode'] = array( '#type' => 'value', - '#value' => $pathAlias['langcode'] + '#value' => $path_alias['langcode'] ); } @@ -141,10 +147,10 @@ public function buildForm(array $form, array &$form_state, $pid = NULL) { '#type' => 'submit', '#value' => $this->t('Save'), ); - if ($pathAlias['pid']) { + if ($path_alias['pid']) { $form['pid'] = array( '#type' => 'hidden', - '#value' => $pathAlias['pid'], + '#value' => $path_alias['pid'], ); $form['actions']['delete'] = array( '#type' => 'submit', @@ -192,9 +198,10 @@ public function submitForm(array &$form, array &$form_state) { $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.')); + drupal_set_message($this->t('The alias has been saved.')); $form_state['redirect'] = 'admin/config/search/path'; } + /** * {@inheritdoc} */ diff --git a/core/modules/path/lib/Drupal/path/Form/PathAdminFilterForm.php b/core/modules/path/lib/Drupal/path/Form/PathAdminFilterForm.php index 54caaa4..9c2a6b0 100644 --- a/core/modules/path/lib/Drupal/path/Form/PathAdminFilterForm.php +++ b/core/modules/path/lib/Drupal/path/Form/PathAdminFilterForm.php @@ -14,7 +14,6 @@ */ class PathAdminFilterForm extends FormBase { - /** * Form constructor. * @@ -29,10 +28,15 @@ class PathAdminFilterForm extends FormBase { * The form structure. */ public function buildForm(array $form, array &$form_state, $alias = NULL) { - $form['#attributes'] = array('class' => array('search-form')); - $form['basic'] = array('#type' => 'details', + $form['#attributes'] = array( + 'class' => array('search-form'), + ); + $form['basic'] = array( + '#type' => 'details', '#title' => $this->t('Filter aliases'), - '#attributes' => array('class' => array('container-inline')), + '#attributes' => array( + 'class' => array('container-inline'), + ), ); $form['basic']['filter'] = array( '#type' => 'search', @@ -44,11 +48,13 @@ public function buildForm(array $form, array &$form_state, $alias = NULL) { ); $form['basic']['submit'] = array( '#type' => 'submit', + '#submit' => array(array($this, 'submitFilter')), '#value' => $this->t('Filter'), ); if ($alias) { $form['basic']['reset'] = array( '#type' => 'submit', + '#submit' => array(array($this, 'submitReset')), '#value' => $this->t('Reset'), ); } @@ -65,17 +71,27 @@ public function validateForm(array &$form, array &$form_state) { } /** - * {@inheritdoc} + * Filter Form submission handler. + * + * @param array $form + * An associative array containing the structure of the form. + * @param array $form_state + * An associative array containing the current state of the form. */ - public function submitForm(array &$form, array &$form_state) { - $op = $form_state['values']['op']; - switch ($op) { - case $this->t('Filter'): - $_SESSION['path_admin_filter_form'] = trim($form_state['values']['filter']); - break; - case $this->t('Reset'): - $_SESSION['path_admin_filter_form'] = NULL; - break; - } + public function submitFilter(array &$form, array &$form_state) { + $_SESSION['path_admin_filter_form'] = trim($form_state['values']['filter']); } + + /** + * Reset Form submission handler. + * + * @param array $form + * An associative array containing the structure of the form. + * @param array $form_state + * An associative array containing the current state of the form. + */ + public function submitReset(array &$form, array &$form_state) { + $_SESSION['path_admin_filter_form'] = NULL; + } + } diff --git a/core/modules/path/lib/Drupal/path/Tests/PathAliasTest.php b/core/modules/path/lib/Drupal/path/Tests/PathAliasTest.php index 89d82a7..87ca4be 100644 --- a/core/modules/path/lib/Drupal/path/Tests/PathAliasTest.php +++ b/core/modules/path/lib/Drupal/path/Tests/PathAliasTest.php @@ -7,9 +7,6 @@ namespace Drupal\path\Tests; -use Drupal\Core\Database\Database; -use Drupal\Core\Path\AliasWhitelist; - /** * Tests path alias functionality. */