3 namespace Drupal\redirect_404\Controller;
5 use Drupal\Core\Config\ConfigFactoryInterface;
6 use Drupal\Core\Controller\ControllerBase;
8 use Drupal\redirect_404\RedirectNotFoundStorageInterface;
9 use Symfony\Component\DependencyInjection\ContainerInterface;
10 use Symfony\Component\HttpFoundation\Request;
13 * Controller to ignore a path from the 'Fix 404 pages' page.
15 class Fix404IgnoreController extends ControllerBase {
20 * @var \Drupal\Core\Config\ConfigFactoryInterface
22 protected $configuration;
25 * The redirect storage.
27 * @var \Drupal\redirect_404\RedirectNotFoundStorageInterface
29 protected $redirectStorage;
32 * Constructs a Fix404Ignore object.
34 * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
36 * @param \Drupal\redirect_404\RedirectNotFoundStorageInterface $redirect_storage
39 public function __construct(ConfigFactoryInterface $config_factory, RedirectNotFoundStorageInterface $redirect_storage) {
40 $this->configuration = $config_factory;
41 $this->redirectStorage = $redirect_storage;
47 public static function create(ContainerInterface $container) {
49 $container->get('config.factory'),
50 $container->get('redirect.not_found_storage')
55 * Adds path into the ignored list.
57 * @param \Symfony\Component\HttpFoundation\Request $request
58 * The HttpRequest object representing the current request.
60 * @return \Symfony\Component\HttpFoundation\RedirectResponse
62 public function ignorePath(Request $request) {
63 $ignored_paths = $this->config('redirect_404.settings')->get('pages');
64 $path = $request->query->get('path');
65 $langcode = $request->query->get('langcode');
67 if (empty($ignored_paths) || !strpos($path, $ignored_paths)) {
68 $this->redirectStorage->resolveLogRequest($path, $langcode);
70 drupal_set_message($this->t('Resolved the path %path in the database. Please check the ignored list and save the settings.', [
78 'destination' => Url::fromRoute('redirect_404.fix_404')->getInternalPath(),
82 return $this->redirect('redirect.settings', [], $options);