diff --git a/core/lib/Drupal/Core/EventSubscriber/CustomPageExceptionHtmlSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/CustomPageExceptionHtmlSubscriber.php index c393a34..377f26b 100644 --- a/core/lib/Drupal/Core/EventSubscriber/CustomPageExceptionHtmlSubscriber.php +++ b/core/lib/Drupal/Core/EventSubscriber/CustomPageExceptionHtmlSubscriber.php @@ -9,6 +9,7 @@ use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Path\AliasManagerInterface; +use Drupal\Core\Routing\RedirectDestinationInterface; use Psr\Log\LoggerInterface; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent; @@ -44,9 +45,11 @@ class CustomPageExceptionHtmlSubscriber extends DefaultExceptionHtmlSubscriber { * The HTTP Kernel service. * @param \Psr\Log\LoggerInterface $logger * The logger service. + * @param \Drupal\Core\Routing\RedirectDestinationInterface $redirect_destination + * The redirect destination service. */ - public function __construct(ConfigFactoryInterface $config_factory, AliasManagerInterface $alias_manager, HttpKernelInterface $http_kernel, LoggerInterface $logger) { - parent::__construct($http_kernel, $logger); + public function __construct(ConfigFactoryInterface $config_factory, AliasManagerInterface $alias_manager, HttpKernelInterface $http_kernel, LoggerInterface $logger, RedirectDestinationInterface $redirect_destination) { + parent::__construct($http_kernel, $logger, $redirect_destination); $this->configFactory = $config_factory; $this->aliasManager = $alias_manager; } diff --git a/core/tests/Drupal/Tests/Core/EventSubscriber/CustomPageExceptionHtmlSubscriberTest.php b/core/tests/Drupal/Tests/Core/EventSubscriber/CustomPageExceptionHtmlSubscriberTest.php index 5b73c85..ffb2a21 100644 --- a/core/tests/Drupal/Tests/Core/EventSubscriber/CustomPageExceptionHtmlSubscriberTest.php +++ b/core/tests/Drupal/Tests/Core/EventSubscriber/CustomPageExceptionHtmlSubscriberTest.php @@ -65,6 +65,13 @@ class CustomPageExceptionHtmlSubscriberTest extends UnitTestCase { protected $customPageSubscriber; /** + * The mocked redirect.destination service. + * + * @var \Drupal\Core\Routing\RedirectDestinationInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $redirectDestination; + + /** * {@inheritdoc} */ protected function setUp() { @@ -73,7 +80,13 @@ protected function setUp() { $this->aliasManager = $this->getMock('Drupal\Core\Path\AliasManagerInterface'); $this->kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface'); $this->logger = $this->getMock('Psr\Log\LoggerInterface'); - $this->customPageSubscriber = new TestCustomPageExceptionHtmlSubscriber($this->configFactory, $this->aliasManager, $this->kernel, $this->logger); + $this->redirectDestination = $this->getMock('\Drupal\Core\Routing\RedirectDestinationInterface'); + + $this->redirectDestination->expects($this->any()) + ->method('getAsArray') + ->willReturn(['destination' => 'test']); + + $this->customPageSubscriber = new CustomPageExceptionHtmlSubscriber($this->configFactory, $this->aliasManager, $this->kernel, $this->logger, $this->redirectDestination); // You can't create an exception in PHP without throwing it. Store the // current error_log, and disable it temporarily. @@ -139,13 +152,3 @@ public function testHandleWithGetRequest() { } -class TestCustomPageExceptionHtmlSubscriber extends CustomPageExceptionHtmlSubscriber { - - /** - * {@inheritdoc} - */ - protected function drupalGetDestination() { - return ['destination' => 'test']; - } - -}