3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
13 * The basic state element. Each state element is linked to a form and
14 * represents the form in the transition diagram. We use the state to
15 * determine what action to take on various user input. Actions include
16 * things like going back / stepping forward / process etc
19 * @copyright CiviCRM LLC https://civicrm.org/licensing
21 class CRM_Core_State
{
30 * This is a combination "OR" of the STATE_* constants defined below
36 * The state that precedes this state.
42 * The state that succeeds this state.
48 * The state machine that this state is part of.
49 * @var CRM_Core_StateMachine
51 protected $_stateMachine;
54 * The different types of states. As we flush out the framework more
55 * we will introduce other conditional / looping states which will
56 * bring in more complexity to the framework. For now, lets keep it simple
59 const START
= 1, FINISH
= 2, SIMPLE
= 4;
65 * Internal name of the state.
68 * @param CRM_Core_State $back
69 * State that precedes this state.
70 * @param CRM_Core_State $next
71 * State that follows this state.
72 * @param CRM_Core_StateMachine $stateMachine
73 * Statemachine that this states belongs to.
75 * @return CRM_Core_State
77 public function __construct($name, $type, $back, $next, &$stateMachine) {
83 $this->_stateMachine
= &$stateMachine;
87 * Given an CRM Form, jump to the previous page.
89 * @param CRM_Core_Form $page
92 * does a jump to the back state
94 public function handleBackState(&$page) {
95 if ($this->_type
& self
::START
) {
96 $page->handle('display');
99 $back = &$page->controller
->getPage($this->_back
);
100 return $back->handle('jump');
105 * Given an CRM Form, jump to the next page.
107 * @param CRM_Core_Form $page
110 * Does a jump to the nextstate
112 public function handleNextState(&$page) {
113 if ($this->_type
& self
::FINISH
) {
114 $page->handle('process');
117 $next = &$page->controller
->getPage($this->_next
);
118 return $next->handle('jump');
123 * Mark this page as valid for the QFC framework.
127 public function validate(&$data) {
128 $data['valid'][$this->_name
] = TRUE;
132 * Mark this page as invalid for the QFC framework.
136 public function invalidate(&$data) {
137 $data['valid'][$this->_name
] = NULL;
145 public function getName() {
152 * @param string $name
154 public function setName($name) {
155 $this->_name
= $name;
163 public function getType() {