Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
domain-3409936
Manage
Activity
Members
Labels
Plan
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Issue forks
domain-3409936
Commits
c82f391b
Commit
c82f391b
authored
1 year ago
by
Guiu Rocafort Ferrer
Browse files
Options
Downloads
Patches
Plain Diff
Added new method loadAllDomainOverrides to get config overrides across all domains
parent
9b9f5331
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
domain_config/domain_config.services.yml
+1
-1
1 addition, 1 deletion
domain_config/domain_config.services.yml
domain_config/src/DomainConfigOverrider.php
+53
-1
53 additions, 1 deletion
domain_config/src/DomainConfigOverrider.php
with
54 additions
and
2 deletions
domain_config/domain_config.services.yml
+
1
−
1
View file @
c82f391b
...
...
@@ -3,7 +3,7 @@ services:
class
:
Drupal\domain_config\DomainConfigOverrider
tags
:
-
{
name
:
config.factory.override
,
priority
:
-150
}
arguments
:
[
'
@config.storage'
,
'
@module_handler'
]
arguments
:
[
'
@config.storage'
,
'
@module_handler'
,
'
@entity_type.manager'
]
domain_config.library.discovery.collector
:
decorates
:
library.discovery.collector
...
...
This diff is collapsed.
Click to expand it.
domain_config/src/DomainConfigOverrider.php
+
53
−
1
View file @
c82f391b
...
...
@@ -2,6 +2,7 @@
namespace
Drupal\domain_config
;
use
Drupal\Core\Entity\EntityTypeManagerInterface
;
use
Drupal\domain\DomainInterface
;
use
Drupal\Core\Cache\CacheableMetadata
;
use
Drupal\Core\Config\ConfigFactoryOverrideInterface
;
...
...
@@ -60,6 +61,15 @@ class DomainConfigOverrider implements ConfigFactoryOverrideInterface {
*/
protected
$languageManager
;
/**
* Domain entity storage.
*
* The domain entity storage.
*
* @var \Drupal\domain\DomainStorageInterface
*/
protected
$domainStorage
;
/**
* Indicates that the request context is set.
*
...
...
@@ -74,10 +84,16 @@ class DomainConfigOverrider implements ConfigFactoryOverrideInterface {
* The configuration storage engine.
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
* The module handler.
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* The entity type manager.
*/
public
function
__construct
(
StorageInterface
$storage
,
ModuleHandlerInterface
$module_handler
)
{
public
function
__construct
(
StorageInterface
$storage
,
ModuleHandlerInterface
$module_handler
,
EntityTypeManagerInterface
$entity_type_manager
)
{
$this
->
storage
=
$storage
;
$this
->
moduleHandler
=
$module_handler
;
$this
->
domainStorage
=
$entity_type_manager
->
getStorage
(
'domain'
);
}
/**
...
...
@@ -163,6 +179,42 @@ class DomainConfigOverrider implements ConfigFactoryOverrideInterface {
}
}
/**
* Return config overrides across all ( or ony active ) domains.
*
* @param array $names
* A list of configuration names that are being loaded.
* @param bool $only_active
* Whether to load overrides only for active domains or all.
*
* @return array
* An array keyed by domain name, then configuration name of override data.
* Override data contains a nested array structure of overrides.
*/
public
function
loadAllDomainOverrides
(
$names
,
$only_active
=
FALSE
):
array
{
$result
=
[];
if
(
$only_active
)
{
$domains
=
$this
->
domainStorage
->
loadByProperties
([
'active'
=>
1
]);
}
else
{
$domains
=
$this
->
domainStorage
->
loadMultiple
();
}
foreach
(
$names
as
$name
)
{
$result
[
$name
]
=
[];
foreach
(
$domains
as
$domain
)
{
$configName
=
$this
->
getDomainConfigName
(
$name
,
$domain
);
if
(
$this
->
storage
->
exists
(
$configName
[
'domain'
]))
{
$result
[
$name
][
$domain
->
id
()]
=
$this
->
storage
->
read
(
$configName
[
'domain'
]);
}
}
}
return
$result
;
}
/**
* Get configuration name for this hostname.
*
...
...
This diff is collapsed.
Click to expand it.
Guiu Rocafort Ferrer
@guiu.rocafort.ferrer
mentioned in commit
2250e6bc
·
1 year ago
mentioned in commit
2250e6bc
mentioned in commit 2250e6bc61966690f1732dfcb0170b68a1b61c98
Toggle commit list
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment