Chris@18: getOperation($route_match); Chris@18: if (!preg_match('/^(?add|update|delete)-(?state|transition)$/', $workflow_operation, $matches)) { Chris@18: throw new \Exception("Invalid _workflow_access operation '$workflow_operation' specified for route '{$route_match->getRouteName()}'."); Chris@18: } Chris@18: Chris@18: $parameters = $route_match->getParameters(); Chris@18: $workflow = $parameters->get('workflow'); Chris@18: if ($workflow && $matches['operation'] === 'add') { Chris@18: return $workflow->access($workflow_operation, $account, TRUE); Chris@18: } Chris@18: if ($workflow && $type = $parameters->get(sprintf('workflow_%s', $matches['type']))) { Chris@18: return $workflow->access(sprintf('%s:%s', $workflow_operation, $type), $account, TRUE); Chris@18: } Chris@18: Chris@18: return AccessResult::neutral(); Chris@18: } Chris@18: Chris@18: /** Chris@18: * Get the operation that will be used for the access check Chris@18: * Chris@18: * @param \Drupal\Core\Routing\RouteMatchInterface $route_match Chris@18: * The parametrized route Chris@18: * Chris@18: * @return string Chris@18: * The access operation. Chris@18: */ Chris@18: protected function getOperation(RouteMatchInterface $route_match) { Chris@18: return $route_match->getRouteObject()->getRequirement('_workflow_access'); Chris@18: } Chris@18: Chris@18: }