Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
ai_interpolator
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
ai_interpolator
Commits
cc744c7e
Commit
cc744c7e
authored
1 year ago
by
Marcus Johansson
Committed by
Marcus Johansson
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3416190
by Marcus_Johansson: Duplication of configuration items for status on config-imort
parent
2f703d26
Branches
Branches containing commit
Tags
1.0.0-beta1
Tags containing commit
No related merge requests found
Pipeline
#80670
passed
1 year ago
Stage: build
Stage: validate
Stage: test
Changes
1
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ai_interpolator.module
+33
-3
33 additions, 3 deletions
ai_interpolator.module
with
33 additions
and
3 deletions
ai_interpolator.module
+
33
−
3
View file @
cc744c7e
...
...
@@ -36,7 +36,8 @@ function ai_interpolator_entity_presave(EntityInterface $entity) {
* Implements hook_entity_insert().
*/
function
ai_interpolator_entity_insert
(
EntityInterface
$entity
)
{
if
(
$entity
instanceof
FieldConfig
)
{
// Never generate on import since that will be done via the importer.
if
(
$entity
instanceof
FieldConfig
&&
_ai_interpolator_can_import_toggle
())
{
\Drupal
::
service
(
'ai_interpolator.status_field'
)
->
modifyStatusField
(
$entity
->
get
(
'entity_type'
),
$entity
->
get
(
'bundle'
));
}
if
(
_ai_interpolator_entity_can_save_toggle
())
{
...
...
@@ -48,7 +49,7 @@ function ai_interpolator_entity_insert(EntityInterface $entity) {
* Implements hook_entity_update().
*/
function
ai_interpolator_entity_update
(
EntityInterface
$entity
)
{
if
(
$entity
instanceof
FieldConfig
)
{
if
(
$entity
instanceof
FieldConfig
&&
_ai_interpolator_can_import_toggle
()
)
{
\Drupal
::
service
(
'ai_interpolator.status_field'
)
->
modifyStatusField
(
$entity
->
get
(
'entity_type'
),
$entity
->
get
(
'bundle'
));
}
if
(
_ai_interpolator_entity_can_save_toggle
())
{
...
...
@@ -60,11 +61,20 @@ function ai_interpolator_entity_update(EntityInterface $entity) {
* Implements hook_entity_delete().
*/
function
ai_interpolator_entity_delete
(
EntityInterface
$entity
)
{
if
(
$entity
instanceof
FieldConfig
&&
_ai_interpolator_entity_can_save_toggle
())
{
if
(
$entity
instanceof
FieldConfig
&&
_ai_interpolator_entity_can_save_toggle
()
&&
_ai_interpolator_can_import_toggle
()
)
{
\Drupal
::
service
(
'ai_interpolator.status_field'
)
->
modifyStatusField
(
$entity
->
get
(
'entity_type'
),
$entity
->
get
(
'bundle'
));
}
}
/**
* Implements hook_entity_insert().
*/
function
ai_interpolator_config_import_steps_alter
(
&
$context
)
{
// We disable generation from entities while importing, so we don't have a
// mis-match of configurations.
_ai_interpolator_can_import_toggle
(
FALSE
);
}
/**
* Global function to toggle or check if to save.
*
...
...
@@ -84,3 +94,23 @@ function _ai_interpolator_entity_can_save_toggle($newToggle = NULL) {
}
return
$toggle
;
}
/**
* Global function to toggle if import is possible.
*
* @param bool $newToggle
* The new toggle if you want to change it.
*
* @return bool
* If it is possible to import or not.
*/
function
_ai_interpolator_can_import_toggle
(
$newToggle
=
NULL
)
{
static
$toggle
;
// Set default to TRUE.
// @codingStandardsIgnoreLine
$toggle
=
$toggle
===
NULL
?
TRUE
:
$toggle
;
if
(
isset
(
$newToggle
))
{
$toggle
=
$newToggle
;
}
return
$toggle
;
}
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