Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
conditions
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
conditions
Commits
72e21c8a
Commit
72e21c8a
authored
5 months ago
by
Pascal Crott
Committed by
Dominik Wille
5 months ago
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3485489
by hydra: Extends the API to allow loading the raw data from database
parent
c61723db
No related branches found
No related tags found
1 merge request
!13
#3485489 Make getItemsDataByConditionConfiguration public.
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
modules/conditions_field/src/ConditionsFieldService.php
+18
-13
18 additions, 13 deletions
modules/conditions_field/src/ConditionsFieldService.php
modules/conditions_field/src/ConditionsFieldServiceInterface.php
+13
-0
13 additions, 0 deletions
.../conditions_field/src/ConditionsFieldServiceInterface.php
with
31 additions
and
13 deletions
modules/conditions_field/src/ConditionsFieldService.php
+
18
−
13
View file @
72e21c8a
...
...
@@ -18,6 +18,14 @@ class ConditionsFieldService implements ConditionsFieldServiceInterface {
use
ConditionAccessResolverTrait
;
/**
* Stores the loaded data by entity_type_id and configuration checksum.
*
* @var array
* The data from database.
*/
protected
array
$itemsData
=
[];
/**
* Constructs an ConditionsFieldService object.
*
...
...
@@ -74,18 +82,15 @@ class ConditionsFieldService implements ConditionsFieldServiceInterface {
}
/**
* Loads the field data for a given condition configuration from database.
*
* @param string $entity_type_id
* The entity_type_id to load from.
* @param array $condition_configuration
* The condition configuration to check for.
*
* @return array
* The database rows with the condition configuration by entity_type_id.
* {@inheritdoc}
*/
protected
function
getItemsDataByConditionConfiguration
(
string
$entity_type_id
,
array
$condition_configuration
):
array
{
$items_data
=
[];
public
function
getItemsDataByConditionConfiguration
(
string
$entity_type_id
,
array
$condition_configuration
):
array
{
$cache_id
=
md5
(
serialize
(
$condition_configuration
));
// Early return if already built.
if
(
isset
(
$this
->
itemsData
[
$entity_type_id
][
$cache_id
]))
{
return
$this
->
itemsData
[
$entity_type_id
][
$cache_id
];
}
// Check for every possible field.
foreach
(
$this
->
getConditionsFieldDefinitions
(
$entity_type_id
)
as
$field_name
=>
$field_definition
)
{
...
...
@@ -122,7 +127,7 @@ class ConditionsFieldService implements ConditionsFieldServiceInterface {
foreach
(
$result
->
fetchAll
()
as
$item
)
{
$value
=
JSON
::
decode
(
$item
->
{
"
{
$field_name
}
_value"
});
$
items_data
[
$item
->
entity_id
][
$item
->
delta
]
=
[
$
this
->
itemsData
[
$entity_type_id
][
$cache_id
]
[
$item
->
entity_id
][
$item
->
delta
]
=
[
'entity_id'
=>
$item
->
entity_id
,
'delta'
=>
$item
->
delta
,
'value'
=>
$value
,
...
...
@@ -132,7 +137,7 @@ class ConditionsFieldService implements ConditionsFieldServiceInterface {
}
}
return
$
items_data
;
return
$
this
->
itemsData
[
$entity_type_id
][
$cache_id
]
??
[]
;
}
}
This diff is collapsed.
Click to expand it.
modules/conditions_field/src/ConditionsFieldServiceInterface.php
+
13
−
0
View file @
72e21c8a
...
...
@@ -35,4 +35,17 @@ interface ConditionsFieldServiceInterface {
*/
public
function
getConditionsFieldDefinitions
(
string
$entity_type_id
=
NULL
):
array
;
/**
* Loads the field data for a given condition configuration from database.
*
* @param string $entity_type_id
* The entity_type_id to load from.
* @param array $condition_configuration
* The condition configuration to check for.
*
* @return array
* The database rows with the condition configuration by entity_type_id.
*/
public
function
getItemsDataByConditionConfiguration
(
string
$entity_type_id
,
array
$condition_configuration
):
array
;
}
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