public function WorkflowCollector::getWorkflows in Workbench Moderation to Content Moderation 8.2
Returns all unique content type workflows.
Return value
array An array of arrays, each of which is a set of values representing a workflow config entity.
File
- src/
WorkflowCollector.php, line 61
Class
Namespace
Drupal\wbm2cmCode
public function getWorkflows() {
$workflows = [];
/** @var \Drupal\Core\Config\Entity\ConfigEntityInterface $bundle */
foreach ($this
->enabled() as $id => $bundle) {
$states = $bundle
->getThirdPartySetting('workbench_moderation', 'allowed_moderation_states', []);
sort($states);
$hash = sha1(implode('', $states));
if (empty($workflows[$hash])) {
$workflows[$hash] = [
'id' => substr($hash, 0, 8),
'type' => 'content_moderation',
'type_settings' => [
'states' => $this
->mapStates($states),
'transitions' => $this
->mapTransitions($states),
'entity_types' => [],
],
];
}
$bundle_of = $bundle
->getEntityType()
->getBundleOf();
$workflows[$hash]['type_settings']['entity_types'][$bundle_of][] = $id;
}
$i = 0;
foreach ($workflows as &$workflow) {
$workflow['label'] = $this
->t('Workflow @number', [
'@number' => ++$i,
]);
}
return $workflows;
}