protected function createAction($name, $actionTemplate, WorkflowDefinition $definition = null)
    {
        $type = $actionTemplate['type'];
        if (!$type || !class_exists($type)) {
            throw new Exception(_t(
                'WorkflowTemplate.INVALID_TEMPLATE_ACTION',
                'Invalid action class specified in template'
            ));
        }

        $action = $type::create();

        $action->Title = $name;

        if (isset($actionTemplate['properties']) && is_array($actionTemplate['properties'])) {
            foreach ($actionTemplate['properties'] as $prop => $val) {
                $action->$prop = $val;
            }
        }

        // Deal with User + Group many_many relations on an action
        $this->addManyManyToObject($action, $actionTemplate);

        if ($definition) {
            $action->WorkflowDefID = $definition->ID;
        }

        $action->write();

        return $action;
    }
protected function createAction($name, $actionTemplate, WorkflowDefinition $definition = null)
    {
        $type = $actionTemplate['type'];
        if (!$type || !class_exists($type)) {
            throw new Exception(_t(
                'WorkflowTemplate.INVALID_TEMPLATE_ACTION',
                'Invalid action class specified in template'
            ));
        }

        $action = $type::create();

        $action->Title = $name;

        if (isset($actionTemplate['properties']) && is_array($actionTemplate['properties'])) {
            foreach ($actionTemplate['properties'] as $prop => $val) {
                $action->$prop = $val;
            }
        }

        // Deal with User + Group many_many relations on an action
        $this->addManyManyToObject($action, $actionTemplate);

        if ($definition) {
            $action->WorkflowDefID = $definition->ID;
        }

        $action->write();

        return $action;
    }
protected function createAction ( $ name , $ actionTemplate , WorkflowDefinition $ definition = null ) { $ type = $ actionTemplate [ 'type' ] ; if ( ! $ type || ! class_exists ( $ type ) ) { throw new Exception ( _t ( 'WorkflowTemplate.INVALID_TEMPLATE_ACTION' , 'Invalid action class specified in template' ) ) ; } $ action = $ type :: create ( ) ; $ action -> Title = $ name ; if ( isset ( $ actionTemplate [ 'properties' ] ) && is_array ( $ actionTemplate [ 'properties' ] ) ) { foreach ( $ actionTemplate [ 'properties' ] as $ prop => $ val ) { $ action -> $ prop = $ val ; } } // Deal with User + Group many_many relations on an action $ this -> addManyManyToObject ( $ action , $ actionTemplate ) ; if ( $ definition ) { $ action -> WorkflowDefID = $ definition -> ID ; } $ action -> write ( ) ; return $ action ; }
Create a workflow action based on a template

@param string $name
@param array $template
@param WorkflowDefinition $definition
@return WorkflowAction
@throws Exception
Create a workflow action based on a template