diff --git a/src/Config/ConfigReadonlyStorage.php b/src/Config/ConfigReadonlyStorage.php index 43934f5..eebba14 100644 --- a/src/Config/ConfigReadonlyStorage.php +++ b/src/Config/ConfigReadonlyStorage.php @@ -23,13 +23,6 @@ class ConfigReadonlyStorage extends CachedStorage { use ConfigReadonlyWhitelistTrait; /** - * The module handler. - * - * @var \Drupal\Core\Extension\ModuleHandlerInterface - */ - protected $moduleHandler; - - /** * The used lock backend instance. * * @var \Drupal\Core\Lock\LockBackendInterface @@ -61,7 +54,7 @@ class ConfigReadonlyStorage extends CachedStorage { parent::__construct($storage, $cache); $this->lock = $lock; $this->requestStack = $request_stack; - $this->moduleHandler = $module_handler; + $this->setModuleHandler($module_handler); } /** diff --git a/src/ConfigReadonlyWhitelistTrait.php b/src/ConfigReadonlyWhitelistTrait.php index 6f6151a..1121f50 100644 --- a/src/ConfigReadonlyWhitelistTrait.php +++ b/src/ConfigReadonlyWhitelistTrait.php @@ -17,6 +17,23 @@ trait ConfigReadonlyWhitelistTrait { protected $patterns = []; /** + * The module handler. + * + * @var \Drupal\Core\Extension\ModuleHandlerInterface + */ + protected $moduleHandler; + + /** + * Sets the module handler. + * + * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler + * The module handler. + */ + public function setModuleHandler(ModuleHandlerInterface $module_handler) { + $this->moduleHandler = $module_handler; + } + + /** * Get whitelist patterns. * * @return string[] diff --git a/src/EventSubscriber/ReadOnlyFormSubscriber.php b/src/EventSubscriber/ReadOnlyFormSubscriber.php index 300e9d6..3924e13 100644 --- a/src/EventSubscriber/ReadOnlyFormSubscriber.php +++ b/src/EventSubscriber/ReadOnlyFormSubscriber.php @@ -18,20 +18,13 @@ class ReadOnlyFormSubscriber implements EventSubscriberInterface { use ConfigReadonlyWhitelistTrait; /** - * The module handler. - * - * @var \Drupal\Core\Extension\ModuleHandlerInterface - */ - protected $moduleHandler; - - /** * ReadOnlyFormSubscriber constructor. * * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler * The module handler to invoke hooks. */ public function __construct(ModuleHandlerInterface $module_handler) { - $this->moduleHandler = $module_handler; + $this->setModuleHandler($module_handler); } /**