<commit_before><?php
/**
 * Handles interactions triggered by users in the backend of the CMS. Replicate this
 * type of functionality wherever you need UI interaction with workflow. 
 *
 * @author  <EMAIL>
 * @license BSD License (http://silverstripe.org/bsd-license/)
 * @package advancedworkflow
 */
abstract class FrontEndWorkflowController extends Controller {

	public $transitionID;

	abstract function start();
	
	abstract function getContextType();
	
	abstract function getContextObject();
	
	/* Provide method for possible different use cases */
	abstract function getWorkflowDefinition();
		
	public function Form(){
		$svc 			= singleton('WorkflowService');
		$active 		= $svc->getWorkflowFor($this->getContextObject());
		$current 		= $active->CurrentAction();
		$wfFields 		= $active->getFrontEndWorkflowFields();
		$wfActions 		= $active->getFrontEndWorkflowActions();
		
		//@todo - evaluate whether or not this should be done via the ActionInstance->BaseAction in the same manner as the Fields & Actions 
		// does SS require validation for a field if it's not actually rendered? (ie. multi-page form)
		$wfValidator 	= $this->getContextObject()->getRequiredFields();
                
		$this->extend('updateFrontendActions', $wfActions);
		$this->extend('updateFrontendFields', $wfFields);
		$this->extend('updateFrontendValidator', $wfValidator);
                
		$form = new FrontendWorkflowForm($this, 'Form', $wfFields, $wfActions, $wfValidator);
		
		if($data = $this->getContextObject()){
			$form->loadDataFrom($data);
		}
    
		return $form;
	}
	
}<commit_msg>added save abstract method, and transition retrieval<commit_after><?php
/**
 * Handles interactions triggered by users in the backend of the CMS. Replicate this
 * type of functionality wherever you need UI interaction with workflow. 
 *
 * @author  <EMAIL>
 * @license BSD License (http://silverstripe.org/bsd-license/)
 * @package advancedworkflow
 */
abstract class FrontEndWorkflowController extends Controller {

	public $transitionID;
	
	protected $contextObj;

	abstract function start();
	
	abstract function getContextType();
	
	abstract function getContextObject();
	
	/* Provide method for possible different use cases */
	abstract function getWorkflowDefinition();
		
	public function Form(){
		$svc 			= singleton('WorkflowService');
		$active 		= $svc->getWorkflowFor($this->getContextObject());
		$current 		= $active->CurrentAction();
		$wfFields 		= $active->getFrontEndWorkflowFields();
		$wfActions 		= $active->getFrontEndWorkflowActions();
		
		//@todo - evaluate whether or not this should be done via the ActionInstance->BaseAction in the same manner as the Fields & Actions 
		// does SS require validation for a field if it's not actually rendered? (ie. multi-page form)
		$wfValidator 	= $this->getContextObject()->getRequiredFields();
                
		$this->extend('updateFrontendActions', $wfActions);
		$this->extend('updateFrontendFields', $wfFields);
		$this->extend('updateFrontendValidator', $wfValidator);
                
		$form = new FrontendWorkflowForm($this, 'Form', $wfFields, $wfActions, $wfValidator);
		
		if($data = $this->getContextObject()){
			$form->loadDataFrom($data);
		}
    
		return $form;
	}
	
	public function getCurrentTransition() {
		$trans = null;
		
		if ($this->transitionID) {
			$trans = DataObject::get_by_id('WorkflowTransition',$this->transitionID);
		}
		
		return $trans;
	}
	
	/* Save the form Data */
	abstract function save(array $data, Form $form, SS_HTTPRequest $request);
	
}
{'fraction_non_alphanumeric': 0.12080158058142818, 'fraction_numerical': 0.0, 'mean_word_length': 4.227138643067847, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 33, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7312705', 'n_tokens_mistral': 1101, 'n_tokens_neox': 974, 'n_words': 283}