public static function getElementWorkflowConfig(AbstractElement $element)
{
$config = self::getWorkflowManagementConfig();
if (!is_array($config)) {
return null;
}
$elementType = Service::getElementType($element);
$elementSubType = $element->getType();
foreach ($config['workflows'] as $workflow) {
//workflow is not enabled, continue with next
if (isset($workflow['enabled']) && !$workflow['enabled']) {
continue;
}
if (isset($workflow['workflowSubject']) && in_array($elementType, $workflow['workflowSubject']['types'])) {
switch ($elementType) {
case 'asset':
if (isset($workflow['workflowSubject']['assetTypes']) && is_array($workflow['workflowSubject']['assetTypes'])) {
if (in_array($elementSubType, $workflow['workflowSubject']['assetTypes'])) {
return $workflow;
}
} else {
Logger::warning('WorkflowManagement::getClassWorkflowConfig workflow does not feature a valid array of available asset types');
}
break;
case 'document':
if (isset($workflow['workflowSubject']['documentTypes']) && is_array($workflow['workflowSubject']['documentTypes'])) {
if (in_array($elementSubType, $workflow['workflowSubject']['documentTypes'])) {
return $workflow;
}
} else {
Logger::warning('WorkflowManagement::getClassWorkflowConfig workflow does not feature a valid array of available document types');
}
break;
case 'object':
if ($element instanceof ConcreteObject) {
if (isset($workflow['workflowSubject']['classes']) && is_array($workflow['workflowSubject']['classes'])) {
$classId = $element->getClassId();
if (in_array($classId, $workflow['workflowSubject']['classes'])) {
return $workflow;
}
} else {
Logger::warning('WorkflowManagement::getClassWorkflowConfig workflow does not feature a valid array of available class ID\'s');
}
}
break;
default:
//unknown element type, return null
return null;
}
}
}
return null;
}