protected function updateActionTransitions($actionTemplate, $action)
    {
        $transitions = array();
        if (isset($actionTemplate['transitions']) && is_array($actionTemplate['transitions'])) {
            $existing = $action->Transitions();
            $transitionMap = array();
            foreach ($existing as $transition) {
                $transitionMap[$transition->Title] = $transition;
            }

            foreach ($actionTemplate['transitions'] as $transitionName => $transitionTemplate) {
                $target = $transitionTemplate;
                if (is_array($transitionTemplate)) {
                    $to = array_keys($transitionTemplate);
                    $transitionName = $to[0];
                    $target = $transitionTemplate[$transitionName];
                }

                if (isset($transitionMap[$transitionName])) {
                    $transition = $transitionMap[$transitionName];
                } else {
                    $transition = WorkflowTransition::create();
                }

                // Add Member and Group relations to this Transition
                $this->addManyManyToObject($transition, $transitionTemplate);

                $transition->Title = $transitionName;
                $transition->ActionID = $action->ID;
                // we don't have the NextAction yet other than the target name, so we store that against
                // the transition and do a second pass later on to match things up
                $transition->Target = $target;
                $transitions[] = $transition;
            }
        }

        return $transitions;
    }
protected function updateActionTransitions($actionTemplate, $action)
    {
        $transitions = array();
        if (isset($actionTemplate['transitions']) && is_array($actionTemplate['transitions'])) {
            $existing = $action->Transitions();
            $transitionMap = array();
            foreach ($existing as $transition) {
                $transitionMap[$transition->Title] = $transition;
            }

            foreach ($actionTemplate['transitions'] as $transitionName => $transitionTemplate) {
                $target = $transitionTemplate;
                if (is_array($transitionTemplate)) {
                    $to = array_keys($transitionTemplate);
                    $transitionName = $to[0];
                    $target = $transitionTemplate[$transitionName];
                }

                if (isset($transitionMap[$transitionName])) {
                    $transition = $transitionMap[$transitionName];
                } else {
                    $transition = WorkflowTransition::create();
                }

                // Add Member and Group relations to this Transition
                $this->addManyManyToObject($transition, $transitionTemplate);

                $transition->Title = $transitionName;
                $transition->ActionID = $action->ID;
                // we don't have the NextAction yet other than the target name, so we store that against
                // the transition and do a second pass later on to match things up
                $transition->Target = $target;
                $transitions[] = $transition;
            }
        }

        return $transitions;
    }
protected function updateActionTransitions ( $ actionTemplate , $ action ) { $ transitions = array ( ) ; if ( isset ( $ actionTemplate [ 'transitions' ] ) && is_array ( $ actionTemplate [ 'transitions' ] ) ) { $ existing = $ action -> Transitions ( ) ; $ transitionMap = array ( ) ; foreach ( $ existing as $ transition ) { $ transitionMap [ $ transition -> Title ] = $ transition ; } foreach ( $ actionTemplate [ 'transitions' ] as $ transitionName => $ transitionTemplate ) { $ target = $ transitionTemplate ; if ( is_array ( $ transitionTemplate ) ) { $ to = array_keys ( $ transitionTemplate ) ; $ transitionName = $ to [ 0 ] ; $ target = $ transitionTemplate [ $ transitionName ] ; } if ( isset ( $ transitionMap [ $ transitionName ] ) ) { $ transition = $ transitionMap [ $ transitionName ] ; } else { $ transition = WorkflowTransition :: create ( ) ; } // Add Member and Group relations to this Transition $ this -> addManyManyToObject ( $ transition , $ transitionTemplate ) ; $ transition -> Title = $ transitionName ; $ transition -> ActionID = $ action -> ID ; // we don't have the NextAction yet other than the target name, so we store that against // the transition and do a second pass later on to match things up $ transition -> Target = $ target ; $ transitions [ ] = $ transition ; } } return $ transitions ; }
Update the transitions for a given action

@param array $actionTemplate
@param WorkflowAction $action

@return array
Update the transitions for a given action