Skip to content
Snippets Groups Projects
Commit 73b1d896 authored by Jürgen Haas's avatar Jürgen Haas
Browse files

Issue #3469441 by jurgenhaas: Make it work with config_ignore

parent 41052619
No related branches found
No related tags found
No related merge requests found
Pipeline #260330 failed
......@@ -5,6 +5,7 @@ namespace Drupal\config_auto_export;
use Drupal\Component\Datetime\Time;
use Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException;
use Drupal\Component\Plugin\Exception\PluginNotFoundException;
use Drupal\config_ignore\ConfigIgnoreConfig;
use Drupal\Core\Config\CachedStorage;
use Drupal\Core\Config\ConfigCrudEvent;
use Drupal\Core\Config\ConfigEvents;
......@@ -34,6 +35,13 @@ class ConfigSubscriber implements EventSubscriberInterface, DestructableInterfac
*/
protected ImmutableConfig $config;
/**
* The config factory.
*
* @var \Drupal\Core\Config\ConfigFactoryInterface
*/
protected ConfigFactoryInterface $configFactory;
/**
* The cache for the storage.
*
......@@ -122,7 +130,7 @@ class ConfigSubscriber implements EventSubscriberInterface, DestructableInterfac
* Constructs a new Settings object.
*
* @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
* An immutable configuration object.
* The config factory.
* @param \Drupal\Core\Config\CachedStorage $config_cache
* The cache for the storage.
* @param \Drupal\Core\Config\FileStorage $config_storage
......@@ -142,6 +150,7 @@ class ConfigSubscriber implements EventSubscriberInterface, DestructableInterfac
*/
public function __construct(ConfigFactoryInterface $config_factory, CachedStorage $config_cache, FileStorage $config_storage, FileSystemInterface $file_system, ModuleHandlerInterface $module_handler, EntityTypeManagerInterface $entity_type_manager, StateInterface $state, Time $time, Service $service) {
$this->config = $config_factory->get('config_auto_export.settings');
$this->configFactory = $config_factory;
$this->configCache = $config_cache;
$this->configStorage = $config_storage;
$this->fileSystem = $file_system;
......@@ -223,6 +232,23 @@ class ConfigSubscriber implements EventSubscriberInterface, DestructableInterfac
return $this->configSplitFiles[$name . '.yml'] ?? FALSE;
}
/**
* Determines if the given config entity is to be ignored.
*
* @param string $name
* The config entity's name.
*
* @return bool
* TRUE, if it is to be ignored, FALSE otherwise.
*/
protected function isIgnored(string $name): bool {
if ($this->moduleHandler->moduleExists('config_ignore')) {
$config = $this->configFactory->get('config_ignore.settings');
return ConfigIgnoreConfig::fromConfig($config)->isIgnored('', $name, 'export', 'update');
}
return FALSE;
}
/**
* Saves changed config to a configurable directory.
*
......@@ -232,6 +258,9 @@ class ConfigSubscriber implements EventSubscriberInterface, DestructableInterfac
public function onConfigSave(ConfigCrudEvent $event): void {
if ($this->active && $this->enabled()) {
$name = $event->getConfig()->getName();
if ($this->isIgnored($name)) {
return;
}
if ($configSplitId = $this->findInConfigSplit($name)) {
$storage = $this->configStorage->createCollection('config_split.' . $configSplitId);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment