WorkflowTypeTestHooks.php
Namespace
Drupal\workflow_type_test\HookFile
-
core/
modules/ workflows/ tests/ modules/ workflow_type_test/ src/ Hook/ WorkflowTypeTestHooks.php
View source
<?php
declare (strict_types=1);
namespace Drupal\workflow_type_test\Hook;
use Drupal\Core\Access\AccessResult;
use Drupal\Core\Access\AccessResultInterface;
use Drupal\workflow_type_test\Plugin\WorkflowType\WorkflowCustomAccessType;
use Drupal\Core\Session\AccountInterface;
use Drupal\workflows\WorkflowInterface;
use Drupal\Core\Hook\Attribute\Hook;
/**
* Hook implementations for workflow_type_test.
*/
class WorkflowTypeTestHooks {
/**
* Implements hook_workflow_type_info_alter().
*/
public function workflowTypeInfoAlter(&$definitions) : void {
// Allow tests to override the workflow type definitions.
$state = \Drupal::state();
if ($state->get('workflow_type_test.plugin_definitions') !== NULL) {
$definitions = $state->get('workflow_type_test.plugin_definitions');
}
}
/**
* Implements hook_ENTITY_TYPE_access() for the Workflow entity type.
*/
public function workflowAccess(WorkflowInterface $entity, $operation, AccountInterface $account) : AccessResultInterface {
if ($entity->getTypePlugin()
->getPluginId() === 'workflow_custom_access_type') {
return WorkflowCustomAccessType::workflowAccess($entity, $operation, $account);
}
return AccessResult::neutral();
}
}
Classes
| Title | Deprecated | Summary |
|---|---|---|
| WorkflowTypeTestHooks | Hook implementations for workflow_type_test. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.