diff --git a/redirect.routing.yml b/redirect.routing.yml index adf86a0..d38af53 100644 --- a/redirect.routing.yml +++ b/redirect.routing.yml @@ -41,7 +41,7 @@ entity.redirect.delete_form: entity.redirect.multiple_delete_confirm: path: '/admin/config/search/redirect/delete' defaults: - _form: '\Drupal\redirect\Form\DeleteMultiple' + _form: '\Drupal\redirect\Form\RedirectDeleteMultipleForm' requirements: _permission: 'administer redirects' diff --git a/src/Form/DeleteMultiple.php b/src/Form/RedirectDeleteMultipleForm.php similarity index 87% rename from src/Form/DeleteMultiple.php rename to src/Form/RedirectDeleteMultipleForm.php index b4f1a2a..9e1ed22 100644 --- a/src/Form/DeleteMultiple.php +++ b/src/Form/RedirectDeleteMultipleForm.php @@ -15,17 +15,17 @@ use Drupal\Core\StringTranslation\TranslationInterface; /** * Provides a redirect deletion confirmation form. */ -class DeleteMultiple extends ConfirmFormBase { +class RedirectDeleteMultipleForm extends ConfirmFormBase { /** * The array of redirects to delete. * * @var string[][] */ - protected $redirects = array(); + protected $redirects = []; /** - * The tempstore factory. + * The private tempstore factory. * * @var \Drupal\user\PrivateTempStoreFactory */ @@ -36,17 +36,17 @@ class DeleteMultiple extends ConfirmFormBase { * * @var \Drupal\Core\Entity\EntityStorageInterface */ - protected $storage; + protected $redirectStorage; /** * The current user. * * @var \Drupal\Core\Session\AccountInterface */ - protected $account; + protected $currentUser; /** - * Constructs a DeleteMultiple form object. + * Constructs a RedirectDeleteMultiple form object. * * @param \Drupal\user\PrivateTempStoreFactory $temp_store_factory * The tempstore factory. @@ -59,8 +59,8 @@ class DeleteMultiple extends ConfirmFormBase { */ public function __construct(PrivateTempStoreFactory $temp_store_factory, EntityTypeManagerInterface $entity_type_manager, AccountInterface $account, TranslationInterface $string_translation) { $this->privateTempStoreFactory = $temp_store_factory; - $this->storage = $entity_type_manager->getStorage('redirect'); - $this->account = $account; + $this->redirectStorage = $entity_type_manager->getStorage('redirect'); + $this->currentUser = $account; $this->setStringTranslation($string_translation); } @@ -108,7 +108,7 @@ class DeleteMultiple extends ConfirmFormBase { * {@inheritdoc} */ public function buildForm(array $form, FormStateInterface $form_state) { - $this->redirects = $this->privateTempStoreFactory->get('redirect_multiple_delete_confirm')->get($this->account->id()); + $this->redirects = $this->privateTempStoreFactory->get('redirect_multiple_delete_confirm')->get($this->currentUser->id()); if (empty($this->redirects)) { return new RedirectResponse($this->getCancelUrl()->setAbsolute()->toString()); } @@ -128,8 +128,8 @@ class DeleteMultiple extends ConfirmFormBase { public function submitForm(array &$form, FormStateInterface $form_state) { if ($form_state->getValue('confirm') && !empty($this->redirects)) { - $this->storage->delete($this->redirects); - $this->privateTempStoreFactory->get('redirect_multiple_delete_confirm')->delete($this->account->id()); + $this->redirectStorage->delete($this->redirects); + $this->privateTempStoreFactory->get('redirect_multiple_delete_confirm')->delete($this->currentUser->id()); $count = count($this->redirects); $this->logger('redirect')->notice('Deleted @count redirects.', ['@count' => $count]); drupal_set_message($this->stringTranslation->formatPlural($count, 'Deleted 1 redirect.', 'Deleted @count redirects.')); diff --git a/src/Tests/RedirectUITest.php b/src/Tests/RedirectUITest.php index 09e360e..5d48c30 100644 --- a/src/Tests/RedirectUITest.php +++ b/src/Tests/RedirectUITest.php @@ -228,6 +228,7 @@ class RedirectUITest extends WebTestBase { $this->assertRaw(t('Are you sure you want to delete the URL redirect from %source to %redirect?', array('%source' => Url::fromUri('base:non-existing', ['query' => ['key' => 'value']])->toString(), '%redirect' => Url::fromUri('base:node')->toString()))); $this->drupalPostForm(NULL, array(), t('Delete')); + $this->assertUrl('admin/config/search/redirect'); // Test the bulk delete action. $this->drupalPostForm(NULL, ['redirect_bulk_form[0]' => TRUE], t('Apply'));