public function getDefinitionFor(DataObject $dataObject)
    {
        if ($dataObject->hasExtension(WorkflowApplicable::class)
            || $dataObject->hasExtension(FileWorkflowApplicable::class)
        ) {
            if ($dataObject->WorkflowDefinitionID) {
                return DataObject::get_by_id(WorkflowDefinition::class, $dataObject->WorkflowDefinitionID);
            }
            if ($dataObject->hasMethod('useInheritedWorkflow') && !$dataObject->useInheritedWorkflow()) {
                return null;
            }
            if ($dataObject->ParentID) {
                return $this->getDefinitionFor($dataObject->Parent());
            }
            if ($dataObject->hasMethod('workflowParent')) {
                $obj = $dataObject->workflowParent();
                if ($obj) {
                    return $this->getDefinitionFor($obj);
                }
            }
        }
        return null;
    }
public function getDefinitionFor(DataObject $dataObject)
    {
        if ($dataObject->hasExtension(WorkflowApplicable::class)
            || $dataObject->hasExtension(FileWorkflowApplicable::class)
        ) {
            if ($dataObject->WorkflowDefinitionID) {
                return DataObject::get_by_id(WorkflowDefinition::class, $dataObject->WorkflowDefinitionID);
            }
            if ($dataObject->hasMethod('useInheritedWorkflow') && !$dataObject->useInheritedWorkflow()) {
                return null;
            }
            if ($dataObject->ParentID) {
                return $this->getDefinitionFor($dataObject->Parent());
            }
            if ($dataObject->hasMethod('workflowParent')) {
                $obj = $dataObject->workflowParent();
                if ($obj) {
                    return $this->getDefinitionFor($obj);
                }
            }
        }
        return null;
    }
public function getDefinitionFor ( DataObject $ dataObject ) { if ( $ dataObject -> hasExtension ( WorkflowApplicable :: class ) || $ dataObject -> hasExtension ( FileWorkflowApplicable :: class ) ) { if ( $ dataObject -> WorkflowDefinitionID ) { return DataObject :: get_by_id ( WorkflowDefinition :: class , $ dataObject -> WorkflowDefinitionID ) ; } if ( $ dataObject -> hasMethod ( 'useInheritedWorkflow' ) && ! $ dataObject -> useInheritedWorkflow ( ) ) { return null ; } if ( $ dataObject -> ParentID ) { return $ this -> getDefinitionFor ( $ dataObject -> Parent ( ) ) ; } if ( $ dataObject -> hasMethod ( 'workflowParent' ) ) { $ obj = $ dataObject -> workflowParent ( ) ; if ( $ obj ) { return $ this -> getDefinitionFor ( $ obj ) ; } } } return null ; }
Gets the workflow definition for a given dataobject, if there is one

Will recursively query parent elements until it finds one, if available

@param DataObject $dataObject
Gets the workflow definition for a given dataobject if there is one