Commit ccbd702c authored by catch's avatar catch
Browse files

Issue #2706241 by mglaman, Spokje, Chi, DamienMcKenna, JeroenT, ankithashetty,...

Issue #2706241 by mglaman, Spokje, Chi, DamienMcKenna, JeroenT, ankithashetty, lslinnet, george.karaivanov, Rade, rteijeiro, nplowman, Wim Leers: AccessAwareRouter does not respect HTTP method

(cherry picked from commit c050f6e9)
parent 60b86d58
Loading
Loading
Loading
Loading
Loading
+3 −6
Original line number Diff line number Diff line
@@ -10,8 +10,8 @@
use Drupal\Core\Routing\RouteObjectInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
use Symfony\Component\Routing\Exception\ResourceNotFoundException;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Symfony\Component\Routing\Exception\ExceptionInterface;
use Symfony\Component\Routing\Matcher\UrlMatcherInterface;

/**
@@ -137,10 +137,7 @@ protected function isAdminPath(Request $request) {
          $path = $this->pathProcessorManager->processInbound(urldecode(rtrim($cloned_request->getPathInfo(), '/')), $cloned_request);
          $attributes = $this->router->match($path);
        }
        catch (ResourceNotFoundException $e) {
          return FALSE;
        }
        catch (AccessDeniedHttpException $e) {
        catch (ExceptionInterface | HttpException) {
          return FALSE;
        }
        $route_object = $attributes[RouteObjectInterface::ROUTE_OBJECT];
+17 −0
Original line number Diff line number Diff line
<?php

namespace Drupal\user_language_test\Controller;

/**
 * Returns responses for User Language Test routes.
 */
class UserLanguageTestController {

  /**
   * Builds the response.
   */
  public function buildPostResponse() {
    return ['#markup' => 'It works!'];
  }

}
+46 −0
Original line number Diff line number Diff line
<?php

namespace Drupal\user_language_test\Form;

use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;

/**
 * Provides a User Language Test form.
 */
class UserLanguageTestForm extends FormBase {

  /**
   * {@inheritdoc}
   */
  public function getFormId() {
    return 'user_language_test';
  }

  /**
   * {@inheritdoc}
   */
  public function buildForm(array $form, FormStateInterface $form_state) {

    $form['#action'] = Url::fromRoute('user_language_test.post_response')->toString();

    $form['actions'] = [
      '#type' => 'actions',
      'submit' => [
        '#type' => 'submit',
        '#value' => $this->t('Send'),
      ],
    ];

    return $form;
  }

  /**
   * {@inheritdoc}
   */
  public function submitForm(array &$form, FormStateInterface $form_state) {

  }

}
+5 −0
Original line number Diff line number Diff line
name: 'User language tests'
type: module
description: 'Support module for user language testing.'
package: Testing
version: VERSION
+16 −0
Original line number Diff line number Diff line
user_language_test.post_response:
  path: '/user-language-test/post'
  defaults:
    _controller: Drupal\user_language_test\Controller\UserLanguageTestController::buildPostResponse
  methods: [post]
  options:
    _admin_route: TRUE
  requirements:
    _access: 'TRUE'

user_language_test.form:
  path: '/user-language-test/form'
  defaults:
    _form: 'Drupal\user_language_test\Form\UserLanguageTestForm'
  requirements:
    _access: 'TRUE'
Loading