<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 4.5 |
+ | CiviCRM version 4.6 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2014 |
+--------------------------------------------------------------------+
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
-*/
+ */
/**
*
class CRM_Core_StateMachine {
/**
- * The controller of this state machine
+ * The controller of this state machine.
* @var object
*/
protected $_controller;
/**
- * The list of states that belong to this state machine
+ * The list of states that belong to this state machine.
* @var array
*/
protected $_states;
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|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;
}
/**
- * 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 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)
+ * @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();
}
/**
- * 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];
}
}
/**
- * 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.
- *
- * @access public
+ * Add sequential pages.
*
- * @param array $pages (reference ) the array of page objects
+ * Meta level function to create a simple wizard for a state machine that is completely sequential.
*
- * @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);
}
/**
- * 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();
}
/**
* @return mixed
*/
- function getDestination() {
+ public function getDestination() {
return $this->_controller->getDestination();
}
/**
* @return mixed
*/
- function getSkipRedirection() {
+ public function getSkipRedirection() {
return $this->_controller->getSkipRedirection();
}
/**
* @return mixed
*/
- function fini() {
+ public function fini() {
return $this->_controller->fini();
}
/**
* @return mixed
*/
- function cancelAction() {
+ public function cancelAction() {
return $this->_controller->cancelAction();
}
* beginning from the final state, but retain the same session
* values
*
- * @return boolean
+ * @return bool
*/
- function shouldReset() {
+ public function shouldReset() {
return TRUE;
-}
+ }
}
-