From 4c11b7a9d0e3d7ef01ac538a70be8e77d9f03d5d Mon Sep 17 00:00:00 2001 From: Alex Pott Date: Wed, 27 Apr 2016 17:12:18 +0100 Subject: [PATCH] Issue #2702001 by olafkarsten, Wim Leers: Inject config factory for BigPipe (including in exception handlers) --- core/modules/big_pipe/big_pipe.services.yml | 2 +- core/modules/big_pipe/src/Render/BigPipe.php | 21 +++++++++++++++----- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/core/modules/big_pipe/big_pipe.services.yml b/core/modules/big_pipe/big_pipe.services.yml index b06255a70a6..52350377320 100644 --- a/core/modules/big_pipe/big_pipe.services.yml +++ b/core/modules/big_pipe/big_pipe.services.yml @@ -11,7 +11,7 @@ services: - { name: placeholder_strategy, priority: 0 } big_pipe: class: Drupal\big_pipe\Render\BigPipe - arguments: ['@renderer', '@session', '@request_stack', '@http_kernel', '@event_dispatcher'] + arguments: ['@renderer', '@session', '@request_stack', '@http_kernel', '@event_dispatcher', '@config.factory'] html_response.attachments_processor.big_pipe: public: false class: \Drupal\big_pipe\Render\BigPipeResponseAttachmentsProcessor diff --git a/core/modules/big_pipe/src/Render/BigPipe.php b/core/modules/big_pipe/src/Render/BigPipe.php index 18f25b89662..3e67737f544 100644 --- a/core/modules/big_pipe/src/Render/BigPipe.php +++ b/core/modules/big_pipe/src/Render/BigPipe.php @@ -8,6 +8,7 @@ use Drupal\Core\Ajax\AjaxResponse; use Drupal\Core\Ajax\ReplaceCommand; use Drupal\Core\Asset\AttachedAssets; use Drupal\Core\Asset\AttachedAssetsInterface; +use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Render\HtmlResponse; use Drupal\Core\Render\RendererInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface; @@ -73,6 +74,13 @@ class BigPipe implements BigPipeInterface { */ protected $eventDispatcher; + /** + * The config factory. + * + * @var \Drupal\Core\Config\ConfigFactoryInterface + */ + protected $configFactory; + /** * Constructs a new BigPipe class. * @@ -86,13 +94,16 @@ class BigPipe implements BigPipeInterface { * The HTTP kernel. * @param \Symfony\Component\EventDispatcher\EventDispatcherInterface $event_dispatcher * The event dispatcher. + * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory + * The config factory. */ - public function __construct(RendererInterface $renderer, SessionInterface $session, RequestStack $request_stack, HttpKernelInterface $http_kernel, EventDispatcherInterface $event_dispatcher) { + public function __construct(RendererInterface $renderer, SessionInterface $session, RequestStack $request_stack, HttpKernelInterface $http_kernel, EventDispatcherInterface $event_dispatcher, ConfigFactoryInterface $config_factory) { $this->renderer = $renderer; $this->session = $session; $this->requestStack = $request_stack; $this->httpKernel = $http_kernel; $this->eventDispatcher = $event_dispatcher; + $this->configFactory = $config_factory; } /** @@ -243,7 +254,7 @@ class BigPipe implements BigPipeInterface { $elements = $this->renderPlaceholder($placeholder, $placeholder_plus_cumulative_settings); } catch (\Exception $e) { - if (\Drupal::config('system.logging')->get('error_level') === ERROR_REPORTING_DISPLAY_VERBOSE) { + if ($this->configFactory->get('system.logging')->get('error_level') === ERROR_REPORTING_DISPLAY_VERBOSE) { throw $e; } else { @@ -280,7 +291,7 @@ class BigPipe implements BigPipeInterface { $html_response = $this->filterEmbeddedResponse($fake_request, $html_response); } catch (\Exception $e) { - if (\Drupal::config('system.logging')->get('error_level') === ERROR_REPORTING_DISPLAY_VERBOSE) { + if ($this->configFactory->get('system.logging')->get('error_level') === ERROR_REPORTING_DISPLAY_VERBOSE) { throw $e; } else { @@ -355,7 +366,7 @@ class BigPipe implements BigPipeInterface { $elements = $this->renderPlaceholder($placeholder_id, $placeholder_render_array); } catch (\Exception $e) { - if (\Drupal::config('system.logging')->get('error_level') === ERROR_REPORTING_DISPLAY_VERBOSE) { + if ($this->configFactory->get('system.logging')->get('error_level') === ERROR_REPORTING_DISPLAY_VERBOSE) { throw $e; } else { @@ -388,7 +399,7 @@ class BigPipe implements BigPipeInterface { $ajax_response = $this->filterEmbeddedResponse($fake_request, $ajax_response); } catch (\Exception $e) { - if (\Drupal::config('system.logging')->get('error_level') === ERROR_REPORTING_DISPLAY_VERBOSE) { + if ($this->configFactory->get('system.logging')->get('error_level') === ERROR_REPORTING_DISPLAY_VERBOSE) { throw $e; } else {