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
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
workflow
Commits
d0f2a3b6
Commit
d0f2a3b6
authored
1 year ago
by
John Voskuilen
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3419812
: RuntimeException: Adding non-existent permissions to a role is not allowed
parent
c16f0931
No related branches found
No related tags found
No related merge requests found
Pipeline
#91118
passed with warnings
1 year ago
Stage: build
Stage: validate
Stage: test
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/Entity/WorkflowManager.php
+4
-3
4 additions, 3 deletions
src/Entity/WorkflowManager.php
src/Entity/WorkflowManagerInterface.php
+6
-3
6 additions, 3 deletions
src/Entity/WorkflowManagerInterface.php
workflow.module
+10
-2
10 additions, 2 deletions
workflow.module
with
20 additions
and
8 deletions
src/Entity/WorkflowManager.php
+
4
−
3
View file @
d0f2a3b6
...
...
@@ -366,13 +366,14 @@ class WorkflowManager implements WorkflowManagerInterface {
/**
* {@inheritdoc}
*/
public
static
function
participateUserRole
s
(
EntityInterface
$workflow
)
{
public
static
function
changeRolePermission
s
(
EntityInterface
$workflow
,
bool
$grant
)
{
$type_id
=
$workflow
->
id
();
$roles
=
workflow_get_user_role_names
(
NULL
);
unset
(
$roles
[
WORKFLOW_ROLE_AUTHOR_RID
]);
// Enable/Disable roles.
foreach
(
$roles
as
$rid
=>
$role
)
{
// Enable role.
$perms
=
[
"create
$type_id
workflow_transition"
=>
1
];
$perms
=
[
"create
$type_id
workflow_transition"
=>
$grant
];
user_role_change_permissions
(
$rid
,
$perms
);
}
}
...
...
This diff is collapsed.
Click to expand it.
src/Entity/WorkflowManagerInterface.php
+
6
−
3
View file @
d0f2a3b6
...
...
@@ -46,14 +46,17 @@ interface WorkflowManagerInterface {
*/
/**
* Implements hook_WORKFLOW_insert().
* Implements hook_ENTITY_TYPE_insert() for 'workflow_type'.
* Implements hook_ENTITY_TYPE_delete() for 'workflow_type'.
*
*
Make sure some roles are allowed
to participate in a Workflow by default.
*
Grant/Revoke all roles
to participate in a Workflow by default.
*
* @param \Drupal\Core\Entity\EntityInterface $workflow
* The workflow object.
* @param bool $grant
* TRUE to grant, FALSE to revoke permissions to participate in workflow.
*/
public
static
function
participateUserRole
s
(
EntityInterface
$workflow
);
public
static
function
changeRolePermission
s
(
EntityInterface
$workflow
,
bool
$grant
);
/**
* Implements hook_user_delete().
...
...
This diff is collapsed.
Click to expand it.
workflow.module
+
10
−
2
View file @
d0f2a3b6
...
...
@@ -151,10 +151,18 @@ function workflow_user_delete($account) {
* Implements hook_ENTITY_TYPE_insert() for 'workflow_type'.
*
* Is called when adding a new Workflow type.
* The technical name for the Workflow entity is 'workflow_type'.
*/
function
workflow_workflow_type_insert
(
EntityInterface
$entity
)
{
WorkflowManager
::
participateUserRoles
(
$entity
);
WorkflowManager
::
changeRolePermissions
(
$entity
,
TRUE
);
}
/**
* Implements hook_ENTITY_TYPE_delete() for 'workflow_type'.
*
* Is called when deleting a new Workflow type.
*/
function
workflow_workflow_type_delete
(
EntityInterface
$entity
)
{
WorkflowManager
::
changeRolePermissions
(
$entity
,
FALSE
);
}
/**
...
...
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