Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
rabbit_hole
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
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
project
rabbit_hole
Commits
993ba290
Commit
993ba290
authored
1 year ago
by
Ivan Doroshenko
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3369030
by Matroskeen: Remove rabbit_hole.behavior_settings.default config
parent
4e8e0974
No related branches found
No related tags found
2 merge requests
!68
Issue #3298741: Fix the issues reported by phpcs
,
!55
Issue #3369030 by Matroskeen: Remove rabbit_hole.behavior_settings.default config.
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
config/install/rabbit_hole.behavior_settings.default.yml
+0
-5
0 additions, 5 deletions
config/install/rabbit_hole.behavior_settings.default.yml
rabbit_hole.install
+9
-0
9 additions, 0 deletions
rabbit_hole.install
src/BehaviorSettingsManager.php
+19
-33
19 additions, 33 deletions
src/BehaviorSettingsManager.php
with
28 additions
and
38 deletions
config/install/rabbit_hole.behavior_settings.default.yml
deleted
100644 → 0
+
0
−
5
View file @
4e8e0974
id
:
default
entity_type_id
:
null
entity_id
:
null
action
:
"
display_page"
configuration
:
{
}
This diff is collapsed.
Click to expand it.
rabbit_hole.install
+
9
−
0
View file @
993ba290
...
...
@@ -335,3 +335,12 @@ function rabbit_hole_update_8108() {
$config
->
save
();
}
}
/**
* Remove useless "rabbit_hole.behavior_settings.default" config.
*/
function
rabbit_hole_update_8109
()
{
\Drupal
::
configFactory
()
->
getEditable
(
'rabbit_hole.behavior_settings.default'
)
->
delete
();
}
This diff is collapsed.
Click to expand it.
src/BehaviorSettingsManager.php
+
19
−
33
View file @
993ba290
...
...
@@ -110,13 +110,20 @@ class BehaviorSettingsManager implements BehaviorSettingsManagerInterface {
$entity_type
=
$this
->
entityTypeManager
->
getStorage
(
$entity_type_id
)
->
getEntityType
();
$bundle_entity_type
=
$entity_type
->
getBundleEntityType
();
if
(
$bundle_entity_type
)
{
$config
=
$this
->
loadBehaviorSettingsAsConfig
(
$bundle_entity_type
,
$bundle
);
}
else
{
$config
=
$this
->
loadBehaviorSettingsAsConfig
(
$entity_type_id
);
$config_id
=
$this
->
generateBehaviorSettingsFullId
(
$bundle_entity_type
,
$bundle
);
$actual
=
$this
->
configFactory
->
get
(
"rabbit_hole.behavior_settings.
{
$config_id
}
"
);
if
(
!
$actual
->
isNew
())
{
return
$actual
->
get
();
}
return
$config
->
get
();
// @todo Remove usage of default config in 3.0.
// Also, there shouldn't be a need for default configuration in the next
// version. If configuration is not available, it should be simply ignored.
$default
=
$this
->
configFactory
->
get
(
'rabbit_hole.behavior_settings.default'
);
return
!
$default
->
isNew
()
?
$default
->
get
()
:
[
'action'
=>
'display_page'
,
'configuration'
=>
[],
];
}
/**
...
...
@@ -150,34 +157,10 @@ class BehaviorSettingsManager implements BehaviorSettingsManagerInterface {
return
$values
;
}
/**
* Loads a config with default settings.
*
* @todo What if the config was manually removed? We should get rid of it and
* keep the defaults somewhere else.
*/
public
function
loadDefaultConfig
()
{
return
$this
->
configFactory
->
get
(
'rabbit_hole.behavior_settings.default'
);
}
/**
* Loads config object for the given entity type and bundle.
*/
protected
function
loadBehaviorSettingsAsConfig
(
string
$entity_type_id
,
?string
$entity_id
=
NULL
)
{
$config_id
=
$this
->
generateBehaviorSettingsFullId
(
$entity_type_id
,
$entity_id
);
$actual
=
$this
->
configFactory
->
get
(
"rabbit_hole.behavior_settings.
{
$config_id
}
"
);
if
(
!
$actual
->
isNew
())
{
return
$actual
;
}
else
{
return
$this
->
loadDefaultConfig
();
}
}
/**
* Generate a full ID based on entity type label, bundle label and entity id.
*
* @param string $entity_type_id
* @param string
|null
$entity_type_id
* The entity type (e.g. node) as a string.
* @param string|null $entity_id
* The entity ID as a string.
...
...
@@ -185,8 +168,11 @@ class BehaviorSettingsManager implements BehaviorSettingsManagerInterface {
* @return string
* The full id appropriate for a BehaviorSettings config entity.
*/
protected
function
generateBehaviorSettingsFullId
(
string
$entity_type_id
,
?string
$entity_id
=
NULL
):
string
{
return
$entity_type_id
.
(
isset
(
$entity_id
)
?
'_'
.
$entity_id
:
''
);
protected
function
generateBehaviorSettingsFullId
(
?string
$entity_type_id
,
?string
$entity_id
=
NULL
):
string
{
if
(
$entity_type_id
)
{
return
$entity_type_id
.
(
isset
(
$entity_id
)
?
'_'
.
$entity_id
:
''
);
}
return
$entity_id
;
}
}
This diff is collapsed.
Click to expand it.
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