Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
entity_workflow
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
entity_workflow
Commits
610424bf
There was an error fetching the commit references. Please try again later.
Commit
610424bf
authored
4 years ago
by
Andrei Mateescu
Browse files
Options
Downloads
Patches
Plain Diff
Bring back entity_workflow_has_entity_state().
parent
18bd4555
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
entity_workflow.module
+59
-0
59 additions, 0 deletions
entity_workflow.module
with
59 additions
and
0 deletions
entity_workflow.module
+
59
−
0
View file @
610424bf
...
...
@@ -505,3 +505,62 @@ function entity_workflow_get_history($entity_type_id, array $entity_ids, $workfl
return
$transition_logs
;
}
/**
* Check if any of the revisions has a particular workflow state in a workspace.
*
* @param string $workflow_id
* The workflow ID.
* @param string $workspace_id
* The workspace ID.
* @param string $entity_type_id
* The entity type.
* @param array $revision_ids
* The revision IDs.
* @param string $state
* The state.
*
* @return bool
* TRUE if the state was found, FALSE otherwise
*/
function
entity_workflow_has_entity_state
(
$workflow_id
,
$workspace_id
,
$entity_type_id
,
array
$revision_ids
,
$state
)
{
$has_state
=
\Drupal
::
service
(
'workspaces.manager'
)
->
executeInWorkspace
(
$workspace_id
,
function
()
use
(
$workflow_id
,
$entity_type_id
,
$revision_ids
,
$state
)
{
$entity_type
=
\Drupal
::
entityTypeManager
()
->
getDefinition
(
$entity_type_id
);
$field_name
=
entity_workflow_get_field_name
(
$workflow_id
);
$query
=
\Drupal
::
entityTypeManager
()
->
getStorage
(
$entity_type_id
)
->
getQuery
();
if
(
$revision_ids
)
{
$query
->
condition
(
$entity_type
->
getKey
(
'revision'
),
$revision_ids
,
'IN'
);
}
$query
->
condition
(
$field_name
,
$state
)
->
accessCheck
(
FALSE
)
->
count
()
->
range
(
0
,
1
);
return
(
bool
)
$query
->
execute
();
});
return
$has_state
;
}
/**
* Check if revisions have a workflow state other than the parameter.
*
* @param string $workflow_id
* The workflow ID.
* @param string $workspace_id
* The workspace ID.
* @param string $entity_type_id
* The entity type.
* @param array $revision_ids
* The revision IDs.
* @param string $state
* The state.
*
* @return bool
* TRUE if the state was not found, FALSE otherwise
*/
function
entity_workflow_has_not_entity_state
(
$workflow_id
,
$workspace_id
,
$entity_type_id
,
array
$revision_ids
,
$state
)
{
return
!
entity_workflow_has_entity_state
(
$workflow_id
,
$workspace_id
,
$entity_type_id
,
$revision_ids
,
$state
);
}
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