Skip to content
Snippets Groups Projects
Commit 596fa2d9 authored by John Voskuilen's avatar John Voskuilen
Browse files

Issue #3513199: Workflow Access - remove creation of (D7) transitions

parent a7d362ea
Branches
Tags
No related merge requests found
Pipeline #449761 passed with warnings
......@@ -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 node_access_acquire_grants().
* Invoked by NodeAccessControlHandler->acquireGrants(), 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;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment