[NFC] Remove some more of the old cvs blocks
[civicrm-core.git] / CRM / Event / StateMachine / Search.php
CommitLineData
6a488035
TO
1<?php
2/*
3 +--------------------------------------------------------------------+
bc77d7c0 4 | Copyright CiviCRM LLC. All rights reserved. |
6a488035 5 | |
bc77d7c0
TO
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 |
6a488035 9 +--------------------------------------------------------------------+
d25dd0ee 10 */
6a488035
TO
11
12/**
016d95d3 13 * Class CRM_Event_StateMachine_Search
6a488035
TO
14 */
15class CRM_Event_StateMachine_Search extends CRM_Core_StateMachine {
16
17 /**
fe482240 18 * The task that the wizard is currently processing.
6a488035
TO
19 *
20 * @var string
6a488035
TO
21 */
22 protected $_task;
23
24 /**
fe482240 25 * Class constructor.
ca87146b 26 *
016d95d3 27 * @param CRM_Core_Controller $controller
daa78a84 28 * @param int $action
6a488035 29 */
00be9182 30 public function __construct($controller, $action = CRM_Core_Action::NONE) {
6a488035
TO
31 parent::__construct($controller, $action);
32
be2fb01f 33 $this->_pages = [];
6a488035
TO
34
35 $this->_pages['CRM_Event_Form_Search'] = NULL;
36 list($task, $result) = $this->taskName($controller, 'Search');
37 $this->_task = $task;
38
39 if (is_array($task)) {
40 foreach ($task as $t) {
41 $this->_pages[$t] = NULL;
42 }
43 }
44 else {
45 $this->_pages[$task] = NULL;
46 }
47
48 if ($result) {
49 $this->_pages['CRM_Event_Form_Task_Result'] = NULL;
50 }
51
52 $this->addSequentialPages($this->_pages, $action);
53 }
54
55 /**
56 * Determine the form name based on the action. This allows us
57 * to avoid using conditional state machine, much more efficient
58 * and simpler
59 *
d4dd1e85
TO
60 * @param CRM_Core_Controller $controller
61 * The controller object.
6a488035 62 *
77b97be7
EM
63 * @param string $formName
64 *
daa78a84 65 * @return array
a6c01b45 66 * the name of the form that will handle the task
6a488035 67 */
00be9182 68 public function taskName($controller, $formName = 'Search') {
6a488035 69 // total hack, check POST vars and then session to determine stuff
9c1bc317 70 $value = $_POST['task'] ?? NULL;
6a488035
TO
71 if (!isset($value)) {
72 $value = $this->_controller->get('task');
73 }
74 $this->_controller->set('task', $value);
75 return CRM_Event_Task::getTask($value);
76 }
77
78 /**
fe482240 79 * Return the form name of the task.
6a488035
TO
80 *
81 * @return string
6a488035 82 */
00be9182 83 public function getTaskFormName() {
6a488035
TO
84 return CRM_Utils_String::getClassName($this->_task);
85 }
86
87 /**
88 * Since this is a state machine for search and we want to come back to the same state
89 * we dont want to issue a reset of the state session when we are done processing a task
6a488035 90 */
00be9182 91 public function shouldReset() {
6a488035
TO
92 return FALSE;
93 }
96025800 94
6a488035 95}