X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FCore%2FStateMachine.php;h=91c92a3ad83ad01029a24d234f265882365b5870;hb=c503dcf3dc4ec114585dcaa8ffdfdbaab9609da7;hp=5c037548e99c2b95c7f5c924756a3e68923f5e3a;hpb=c11da624176c6f66b876bd1c2750cc389ab993ef;p=civicrm-core.git diff --git a/CRM/Core/StateMachine.php b/CRM/Core/StateMachine.php index 5c037548e9..91c92a3ad8 100644 --- a/CRM/Core/StateMachine.php +++ b/CRM/Core/StateMachine.php @@ -1,7 +1,7 @@ 1 relationship. so u * can always derive one from the other * @var array @@ -64,35 +64,35 @@ class CRM_Core_StateMachine { protected $_pages; /** - * The names of the pages + * The names of the pages. * * @var array */ protected $_pageNames; /** - * the mode that the state machine is operating in + * The mode that the state machine is operating in. * @var int */ protected $_action = NULL; /** - * The display name for this machine + * The display name for this machine. * @var string */ protected $_name = NULL; /** - * class constructor + * Class constructor. * - * @param object $controller the controller for this state machine + * @param object $controller + * The controller for this state machine. * - * @param const $action + * @param \const|int $action * * @return \CRM_Core_StateMachine - @access public */ - function __construct(&$controller, $action = CRM_Core_Action::NONE) { + public function __construct(&$controller, $action = CRM_Core_Action::NONE) { $this->_controller = &$controller; $this->_action = $action; @@ -100,40 +100,42 @@ class CRM_Core_StateMachine { } /** - * getter for name + * Getter for name. * * @return string - * @access public */ public function getName() { return $this->_name; } /** - * setter for name + * Setter for name. * - * @param string + * @param string $name * * @return void - * @access public */ public function setName($name) { $this->_name = $name; } /** - * do a state transition jump. Currently only supported types are + * Do a state transition jump. + * + * Currently only supported types are * Next and Back. The other actions (Cancel, Done, Submit etc) do * not need the state machine to figure out where to go * - * @param object $page CRM_Core_Form the current form-page - * @param string $actionName Current action name, as one Action object can serve multiple actions - * @param string $type The type of transition being requested (Next or Back) + * @param CRM_Core_Form $page + * The current form-page. + * @param string $actionName + * Current action name, as one Action object can serve multiple actions. + * @param string $type + * The type of transition being requested (Next or Back). * * @return void - * @access public */ - function perform(&$page, $actionName, $type = 'Next') { + public function perform(&$page, $actionName, $type = 'Next') { // save the form values and validation status to the session $page->isFormBuilt() or $page->buildForm(); @@ -171,29 +173,33 @@ class CRM_Core_StateMachine { } /** - * helper function to add a State to the state machine + * Helper function to add a State to the state machine. * - * @param string $name the internal name - * @param int $type the type of state (START|FINISH|SIMPLE) - * @param object $prev the previous page if any - * @param object $next the next page if any + * @param string $name + * The internal name. + * @param int $type + * The type of state (START|FINISH|SIMPLE). + * @param object $prev + * The previous page if any. + * @param object $next + * The next page if any. * * @return void - * @access public */ - function addState($name, $type, $prev, $next) { + public function addState($name, $type, $prev, $next) { $this->_states[$name] = new CRM_Core_State($name, $type, $prev, $next, $this); } /** - * Given a name find the corresponding state + * Given a name find the corresponding state. * - * @param string $name the state name + * @param string $name + * The state name. * - * @return object the state object - * @access public + * @return object + * the state object */ - function find($name) { + public function find($name) { if (array_key_exists($name, $this->_states)) { return $this->_states[$name]; } @@ -203,67 +209,62 @@ class CRM_Core_StateMachine { } /** - * return the list of state objects + * Return the list of state objects. * - * @return array array of states in the state machine - * @access public + * @return array + * array of states in the state machine */ - function getStates() { + public function getStates() { return $this->_states; } /** - * return the state object corresponding to the name + * Return the state object corresponding to the name. * - * @param string $name name of page + * @param string $name + * Name of page. * - * @return CRM_Core_State state object matching the name - * @access public + * @return CRM_Core_State + * state object matching the name */ - function &getState($name) { + public function &getState($name) { if (isset($this->_states[$name])) { - return $this->_states[$name]; - } + return $this->_states[$name]; + } /* * This is a gross hack for ajax driven requests where * we change the form name to allow multiple edits to happen * We need a cleaner way of doing this going forward */ - foreach ($this->_states as $n => $s ) { + foreach ($this->_states as $n => $s) { if (substr($name, 0, strlen($n)) == $n) { return $s; } } - return null; + return NULL; } /** - * return the list of form objects + * Return the list of form objects. * - * @return array array of pages in the state machine - * @access public + * @return array + * array of pages in the state machine */ - function getPages() { + public function getPages() { return $this->_pages; } /** - * addSequentialStates: meta level function to create a simple - * wizard for a state machine that is completely sequential. + * Add sequential pages. * - * @access public + * Meta level function to create a simple wizard for a state machine that is completely sequential. * - * @param array $pages (reference ) the array of page objects - * - * @internal param array $states states is an array of arrays. Each element - * of the top level array describes a state. Each state description - * includes the name, the display name and the class name - * - * @return void + * @param array $pages + * (reference ) the array of page objects. */ - function addSequentialPages(&$pages) { + public function addSequentialPages(&$pages) { $this->_pages = &$pages; $numPages = count($pages); @@ -316,60 +317,69 @@ class CRM_Core_StateMachine { } /** - * reset the state machine + * Reset the state machine. * * @return void - * @access public */ - function reset() { + public function reset() { $this->_controller->reset(); } /** - * getter for action + * Getter for action. * * @return int - * @access public */ - function getAction() { + public function getAction() { return $this->_action; } /** - * setter for content + * Setter for content. * - * @param string $content the content generated by this state machine + * @param string $content + * The content generated by this state machine. * * @return void - * @access public */ - function setContent(&$content) { + public function setContent(&$content) { $this->_controller->setContent($content); } /** - * getter for content + * Getter for content. * * @return string - * @access public */ - function &getContent() { + public function &getContent() { return $this->_controller->getContent(); } - function getDestination() { + /** + * @return mixed + */ + public function getDestination() { return $this->_controller->getDestination(); } - function getSkipRedirection() { + /** + * @return mixed + */ + public function getSkipRedirection() { return $this->_controller->getSkipRedirection(); } - function fini() { + /** + * @return mixed + */ + public function fini() { return $this->_controller->fini(); } - function cancelAction() { + /** + * @return mixed + */ + public function cancelAction() { return $this->_controller->cancelAction(); } @@ -380,11 +390,10 @@ class CRM_Core_StateMachine { * beginning from the final state, but retain the same session * values * - * @return boolean + * @return bool */ - function shouldReset() { + public function shouldReset() { return TRUE; -} + } } -