diff --git a/core/modules/path/src/Form/PathFilterForm.php b/core/modules/path/src/Form/PathFilterForm.php index 9ff0c34f21..0e07aac5d0 100644 --- a/core/modules/path/src/Form/PathFilterForm.php +++ b/core/modules/path/src/Form/PathFilterForm.php @@ -4,6 +4,7 @@ use Drupal\Core\Form\FormBase; use Drupal\Core\Form\FormStateInterface; +use Drupal\Core\Language\LanguageInterface; /** * Provides the path admin overview filter form. @@ -22,7 +23,7 @@ public function getFormId() { /** * {@inheritdoc} */ - public function buildForm(array $form, FormStateInterface $form_state, $keys = NULL) { + public function buildForm(array $form, FormStateInterface $form_state, $query = []) { $form['#attributes'] = ['class' => ['search-form']]; $form['basic'] = [ '#type' => 'details', @@ -30,19 +31,40 @@ public function buildForm(array $form, FormStateInterface $form_state, $keys = N '#open' => TRUE, '#attributes' => ['class' => ['container-inline']], ]; - $form['basic']['filter'] = [ + $form['basic']['alias'] = [ '#type' => 'search', '#title' => $this->t('Path alias'), + '#attributes' => [ + 'placeholder' => $this->t('Path alias'), + ], '#title_display' => 'invisible', - '#default_value' => $keys, + '#default_value' => $query['alias'] ?? NULL, '#maxlength' => 128, '#size' => 25, ]; + $form['basic']['path'] = [ + '#type' => 'search', + '#title' => $this->t('System path'), + '#attributes' => [ + 'placeholder' => $this->t('System path'), + ], + '#title_display' => 'invisible', + '#default_value' => $query['path'] ?? NULL, + '#maxlength' => 128, + '#size' => 25, + ]; + $form['basic']['langcode'] = [ + '#type' => 'language_select', + '#languages' => LanguageInterface::STATE_ALL, + '#title' => $this->t('Language'), + '#title_display' => 'invisible', + '#default_value' => $query['langcode'] ?? 'und', + ]; $form['basic']['submit'] = [ '#type' => 'submit', '#value' => $this->t('Filter'), ]; - if ($keys) { + if ($query) { $form['basic']['reset'] = [ '#type' => 'submit', '#value' => $this->t('Reset'), @@ -57,7 +79,11 @@ public function buildForm(array $form, FormStateInterface $form_state, $keys = N */ public function submitForm(array &$form, FormStateInterface $form_state) { $form_state->setRedirect('entity.path_alias.collection', [], [ - 'query' => ['search' => trim($form_state->getValue('filter'))], + 'query' => [ + 'alias' => trim($form_state->getValue('alias')), + 'path' => trim($form_state->getValue('path')), + 'langcode' => trim($form_state->getValue('langcode')), + ], ]); } diff --git a/core/modules/path/src/PathAliasListBuilder.php b/core/modules/path/src/PathAliasListBuilder.php index 8f980f190f..a01ef915b9 100644 --- a/core/modules/path/src/PathAliasListBuilder.php +++ b/core/modules/path/src/PathAliasListBuilder.php @@ -95,9 +95,15 @@ public static function createInstance(ContainerInterface $container, EntityTypeI protected function getEntityIds() { $query = $this->getStorage()->getQuery()->accessCheck(TRUE); - $search = $this->currentRequest->query->get('search'); - if ($search) { - $query->condition('alias', $search, 'CONTAINS'); + if ($alias = $this->currentRequest->query->get('alias')) { + $query->condition('alias', $alias, 'CONTAINS'); + } + if ($path = $this->currentRequest->query->get('path')) { + $query->condition('path', $path, 'CONTAINS'); + } + $langcode = $this->currentRequest->query->get('langcode'); + if ($langcode && $langcode !== 'und') { + $query->condition('langcode', $langcode); } // Only add the pager if a limit is specified. @@ -116,8 +122,8 @@ protected function getEntityIds() { * {@inheritdoc} */ public function render() { - $keys = $this->currentRequest->query->get('search'); - $build['path_admin_filter_form'] = $this->formBuilder->getForm(PathFilterForm::class, $keys); + $query = $this->currentRequest->query->all(); + $build['path_admin_filter_form'] = $this->formBuilder->getForm(PathFilterForm::class, $query); $build += parent::render(); $build['table']['#empty'] = $this->t('No path aliases available. Add URL alias.', [':link' => Url::fromRoute('entity.path_alias.add_form')->toString()]);