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
a1d49de4
Commit
a1d49de4
authored
1 year ago
by
John Voskuilen
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#2919482
: phpcs workflow.module file
parent
ea09a485
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Pipeline
#89676
passed with warnings
1 year ago
Stage: build
Stage: validate
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
workflow.module
+38
-49
38 additions, 49 deletions
workflow.module
with
38 additions
and
49 deletions
workflow.module
+
38
−
49
View file @
a1d49de4
...
...
@@ -45,7 +45,7 @@ use Drupal\workflow\Entity\WorkflowTransitionInterface;
*/
/**
* @inheritdoc
*
{
@inheritdoc
}
*/
function
workflow_help
(
$route_name
)
{
$output
=
''
;
...
...
@@ -57,6 +57,7 @@ function workflow_help($route_name) {
store field values as Workflow states. You can control "state transitions"
and add action to specific transitions.'
)
.
'</p>'
;
return
$output
;
case
'entity.workflow_transition.field_ui_fields'
:
return
t
(
'This page allows you to add fields to the Workflow form.
Normally this is an advanced action, which is not needed in
...
...
@@ -95,13 +96,13 @@ function workflow_help($route_name) {
[
':url'
=>
$url
->
toString
()]);
case
'entity.workflow_transition_label.collection'
:
return
t
(
'
You can add labels to transitions if you don
\
't like the
return
t
(
"
You can add labels to transitions if you don't like the
standard state labels. They will modify the Workflow form options, so
specific workflow transitions can have their own labels, relative to
the beginning and ending states. Rather than showing the user a
workflow box containing options like
"
review required
"
as a state in
the workflow, it could say
"
move to the editing department for grammar
review
".'
);
workflow box containing options like
'
review required
'
as a state in
the workflow, it could say
'
move to the editing department for grammar
review
'."
);
}
return
$output
;
}
...
...
@@ -128,14 +129,8 @@ function workflow_hook_info() {
* ALERT: This may cause previously non-Anonymous posts to suddenly
* be accessible to Anonymous.
*
* @param $edit
* @param \Drupal\Core\Session\AccountInterface $account
* An account object.
* @param string $method
*
* @see hook_user_cancel()
*/
function
workflow_user_cancel
(
$edit
,
AccountInterface
$account
,
$method
)
{
WorkflowManager
::
cancelUser
(
$edit
,
$account
,
$method
);
}
...
...
@@ -143,9 +138,6 @@ function workflow_user_cancel($edit, AccountInterface $account, $method) {
/**
* Implements hook_user_delete().
*
* @param \Drupal\Core\Session\AccountInterface $account
* An account object.
*
* @todo Hook hook_user_delete does not exist. hook_ENTITY_TYPE_delete?
*/
function
workflow_user_delete
(
$account
)
{
...
...
@@ -157,9 +149,6 @@ function workflow_user_delete($account) {
*
* Is called when adding a new Workflow type.
* The technical name for the Workflow entity is 'workflow_type'.
*
* @param \Drupal\Core\Entity\EntityInterface $entity
* An Entity.
*/
function
workflow_workflow_type_insert
(
EntityInterface
$entity
)
{
WorkflowManager
::
participateUserRoles
(
$entity
);
...
...
@@ -167,9 +156,6 @@ function workflow_workflow_type_insert(EntityInterface $entity) {
/**
* Implements hook_entity_insert().
*
* @param \Drupal\Core\Entity\EntityInterface $entity
* An Entity.
*/
function
workflow_entity_insert
(
EntityInterface
$entity
)
{
// Execute updates in hook_presave() to revert executions,
...
...
@@ -179,9 +165,6 @@ function workflow_entity_insert(EntityInterface $entity) {
/**
* Implements hook_entity_presave().
*
* @param \Drupal\Core\Entity\EntityInterface $entity
* An EntityInterface object.
*/
function
workflow_entity_presave
(
EntityInterface
$entity
)
{
if
(
!
$entity
->
isNew
())
{
...
...
@@ -191,10 +174,11 @@ function workflow_entity_presave(EntityInterface $entity) {
}
/**
* Execute transitions. if prohibited, restore original field value.
* - insert: use hook_insert(), to have the Entity ID determined when saving transitions.
* - update: use hook_presave() to revert executions,
* - so, do not use hook_update().
* Execute transitions. If prohibited, restore original field value.
*
* - insert: use hook_insert(), to have the Entity ID determined when saving transitions.
* - update: use hook_presave() to revert executions,
* - so, do not use hook_update().
*
* @param \Drupal\Core\Entity\EntityInterface $entity
* An Entity.
...
...
@@ -213,9 +197,6 @@ function _workflow_execute_transitions(EntityInterface $entity) {
* Implements hook_entity_delete().
*
* Delete the corresponding workflow table records.
*
* @param \Drupal\Core\Entity\EntityInterface $entity
* An Entity.
*/
function
workflow_entity_delete
(
EntityInterface
$entity
)
{
// @todo Test with multiple workflows.
...
...
@@ -268,7 +249,7 @@ function workflow_theme() {
'workflow_transition'
=>
[
'render element'
=>
'elements'
,
'file'
=>
'workflow.theme.inc'
,
]
]
,
];
}
...
...
@@ -277,6 +258,8 @@ function workflow_theme() {
*/
/**
* Executes transition and update the attached entity.
*
* @param \Drupal\workflow\Entity\WorkflowTransitionInterface $transition
* A WorkflowTransition.
* @param bool $force
...
...
@@ -284,14 +267,16 @@ function workflow_theme() {
*
* @return string
* A string.
*
* @deprecated 8.x-1.7
*/
function
workflow_execute_transition
(
WorkflowTransitionInterface
$transition
,
$force
=
FALSE
)
{
// Execute transition and update the attached entity.
return
$transition
->
executeAndUpdateEntity
(
$force
);
}
/**
* Functions to get an options list (to show in a Widget).
*
* To be used in non-OO modules, like workflow_rules, workflow_views.
*
* The naming convention is workflow_get_<entity_type>_names.
...
...
@@ -306,12 +291,11 @@ function workflow_execute_transition(WorkflowTransitionInterface $transition, $f
/**
* Retrieves the names of roles matching specified conditions.
*
*
D
eprecated D
8
: workflow_get_roles --> workflow_get_user_role_names.
*
@_d
eprecated D
7
: workflow_get_roles --> workflow_get_user_role_names.
*
* Usage:
* D7: $roles = workflow_get_user_role_names('participate in workflow');
* D8: $type_id = $workflow->id();
* D8: $roles = workflow_get_user_role_names("create $type_id workflow_transition");
* $type_id = $workflow->id();
* $roles = workflow_get_user_role_names("create $type_id workflow_transition");
*
* @param string $permission
* (optional) A string containing a permission. If set, only roles
...
...
@@ -348,16 +332,16 @@ function workflow_get_user_role_names($permission) {
*
* @return array
* An array of $sid => state->label(), grouped per Workflow.
*
* @see callback_allowed_values_function()
* @see options_allowed_values()
*
* @todo Implement $add parameter.
* @todo Follow Options pattern
*/
function
workflow_get_workflow_state_names
(
$wid
=
''
,
$grouped
=
FALSE
)
{
$options
=
[];
// @todo Implement $add parameter.
//
// @todo Follow Options pattern.
// @see callback_allowed_values_function()
// @see options_allowed_values()
// Get the (user-dependent) options.
// Since this function is only used in UI, it is save to use the global $user.
$user
=
workflow_current_user
();
...
...
@@ -384,8 +368,10 @@ function workflow_get_workflow_state_names($wid = '', $grouped = FALSE) {
}
/**
* Get an options list for workflows. Include an initial empty value
* if requested. Validate each workflow, and generate a message if not complete.
* Get an options list for workflows.
*
* Includes an initial empty value if requested.
* Validate each workflow, and generate a message if not complete.
*
* @param bool $required
* Indicates if the resulting list contains a options value.
...
...
@@ -435,7 +421,8 @@ function workflow_get_workflow_field_names(EntityInterface $entity = NULL, $enti
/**
* Helper function, to get the label of a given State Id.
* deprecated: workflow_get_sid_label() --> workflow_get_sid_name()
*
* @deprecated: workflow_get_sid_label() --> workflow_get_sid_name()
*
* @param string $sid
* A State ID.
...
...
@@ -460,6 +447,7 @@ function workflow_get_sid_name($sid) {
/**
* Determines the Workflow field_name of an entity.
*
* If an entity has multiple workflows, only returns the first one.
*
* @param \Drupal\Core\Entity\EntityInterface $entity
...
...
@@ -468,7 +456,7 @@ function workflow_get_sid_name($sid) {
* The field name. If given, will be passed as return value.
*
* @return string
* The found Field name.
* The found Field name
of the first workflow field
.
*/
function
workflow_get_field_name
(
EntityInterface
$entity
,
$field_name
=
''
)
{
if
(
!
$entity
)
{
...
...
@@ -536,6 +524,7 @@ function workflow_node_previous_state(EntityInterface $entity, $field_name = '')
/**
* Get a specific workflow, given an entity type.
*
* Only one workflow is possible per node type.
* Caveat: gives undefined results with multiple workflows per entity.
* @todo Support multiple workflows per entity.
...
...
@@ -574,9 +563,10 @@ function workflow_get_workflows_by_type($entity_bundle, $entity_type) {
* Finds the Workflow fields on a given Entity type.
*
* @param string $entity_type_id
* The entity type, if needed.
*
The entity type, if needed.
*
* @return mixed
* A list of Workflow fields.
*/
function
workflow_get_workflow_fields_by_entity_type
(
$entity_type_id
=
''
)
{
return
\Drupal
::
service
(
'workflow.manager'
)
->
getFieldMap
(
$entity_type_id
);
...
...
@@ -606,7 +596,6 @@ function _workflow_info_fields($entity = NULL, $entity_type_id = '', $entity_bun
$entity_bundle
=
$entity
->
bundle
();
}
// @todo: Add checks for not-specified Entity type and bundle name.
$field_map
=
\Drupal
::
service
(
'workflow.manager'
)
->
getFieldMap
(
$entity_type_id
);
// Return structure is not consistent.
if
(
$entity_type_id
)
{
...
...
@@ -659,7 +648,7 @@ function _workflow_info_fields($entity = NULL, $entity_type_id = '', $entity_bun
* @param \Drupal\Core\Routing\RouteMatchInterface $route_match
* A route.
*
* @return \Drupal\Core\Entity\EntityInterface
* @return \Drupal\Core\Entity\EntityInterface
|NULL
* Entity from the route.
*/
function
workflow_url_get_entity
(
EntityInterface
$entity
=
NULL
,
RouteMatchInterface
$route_match
=
NULL
)
{
...
...
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