Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
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
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
workflow
Commits
596fa2d9
Commit
596fa2d9
authored
6 months ago
by
John Voskuilen
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3513199
: Workflow Access - remove creation of (D7) transitions
parent
a7d362ea
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Pipeline
#449761
passed with warnings
6 months ago
Stage: build
Stage: validate
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
modules/workflow_access/workflow_access.module
+6
-36
6 additions, 36 deletions
modules/workflow_access/workflow_access.module
with
6 additions
and
36 deletions
modules/workflow_access/workflow_access.module
+
6
−
36
View file @
596fa2d9
...
...
@@ -15,7 +15,6 @@ use Drupal\workflow\Entity\WorkflowInterface;
use
Drupal\workflow\Entity\WorkflowRole
;
use
Drupal\workflow\Entity\WorkflowState
;
use
Drupal\workflow\Entity\WorkflowTargetEntity
;
use
Drupal\workflow\Entity\WorkflowTransition
;
/**
* Implements hook_help().
...
...
@@ -41,13 +40,14 @@ function workflow_access_help($route_name, RouteMatchInterface $route_match) {
the Workflow access module</a>."
,
[
':url'
=>
$url
->
toString
()]
);
if
(
\Drupal
::
moduleHandler
()
->
moduleExists
(
'og'
))
{
// @todo D8: FIXME when OG module is ported.
$output
.
=
'<br>'
;
$output
.
=
t
(
'WARNING: Organic Groups (OG) is present and may interfere
with these settings.'
);
// $output .= ' ';
// $url = Url::fromUri('admin/config/group/settings');
// @todo D8: FIXME when OG module is ported.
// $url = Url::fromUri('admin/config/group/settings');
// $output .= t("In particular, if <a href=':url'>Strict node access
// permissions</a> is enabled, since this may override Workflow access
// settings.", [':url' => $url]);
...
...
@@ -82,13 +82,11 @@ function workflow_access_workflow_operations($op, ?EntityInterface $entity = NUL
break
;
}
// $alt = t('Control content access for @wf', ['@wf' => $label]);
// $attributes = ['alt' => $alt, 'title' => $alt];
$operations
[
'workflow_access'
]
=
[
'title'
=>
t
(
'Access'
),
// $alt = t('Control content access for @wf', ['@wf' => $label]);
// $attributes = ['alt' => $alt, 'title' => $alt];
'weight'
=>
50
,
// @todo use toUrl, using linkTemplates or RouteSubscriber::AlterRoutes().
//'url' => $entity->getWorkflow()->toUrl('access_form'),
'url'
=>
Url
::
fromRoute
(
'entity.workflow_type.access_form'
,
[
'workflow_type'
=>
$wid
]),
'query'
=>
\Drupal
::
destination
()
->
getAsArray
(),
];
...
...
@@ -175,7 +173,7 @@ function workflow_access_get_role_gid($rid) {
* Implements hook_node_access_records().
*
* Returns a list of grant records for the passed in node object.
*
This hook is invoked by function n
ode
_a
ccess
_
acquire
_g
rants().
*
Invoked by N
ode
A
ccess
ControlHandler->
acquire
G
rants()
, node_access_rebuild()
.
*/
function
workflow_access_node_access_records
(
NodeInterface
$node
)
{
$grants
=
[];
...
...
@@ -200,35 +198,7 @@ function workflow_access_node_access_records(NodeInterface $node) {
/** @var \Drupal\node\NodeInterface $translation */
$uid
=
(
int
)
$translation
->
getOwnerId
()
??
0
;
$workflow_transitions
=
$translation
->
workflow_transitions
??
[];
if
(
!
$workflow_transitions
)
{
// Sometimes, a node is saved without going through workflow_transition_form.
// E.g.,
// - when saving a node with workflow_node programmatically with node_save();
// - when changing a state on a node view page/history tab;
// - when rebuilding permissions via batch for Workflow fields.
// In that case, we need to create the workflow_transitions ourselves to
// calculate the grants.
foreach
(
$workflow_field_names
as
$field_name
=>
$label
)
{
// Create a dummy transition, just to set $workflow_transitions.
$old_sid
=
$new_sid
=
$translation
->
{
$field_name
}
->
value
;
if
(
$old_sid
)
{
$transition
=
WorkflowTransition
::
create
([
$old_sid
,
'field_name'
=>
$field_name
])
->
setTargetEntity
(
$translation
)
->
setValues
(
$new_sid
,
$translation
->
getOwnerId
(),
\Drupal
::
time
()
->
getRequestTime
(),
''
);
$workflow_transitions
[
$field_name
]
=
$transition
;
}
}
}
$count_workflow_fields
=
0
;
foreach
(
$workflow_transitions
as
$field_name
=>
$transition
)
{
// @todo Add support for multiple workflows per entity.
if
(
++
$count_workflow_fields
>
1
)
{
continue
;
}
if
(
!
$current_sid
=
workflow_node_current_state
(
$translation
,
$field_name
))
{
continue
;
}
...
...
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
sign in
to comment