(dev/core#1615) Import civicrm-setup code
[civicrm-core.git] / setup / src / Setup / UI / Event / BaseUIEvent.php
1 <?php
2 namespace Civi\Setup\UI\Event;
3
4 use Symfony\Component\EventDispatcher\Event;
5
6 class BaseUIEvent extends Event {
7
8 /**
9 * @var \Civi\Setup\UI\SetupController
10 */
11 protected $ctrl;
12
13 /**
14 * @var string
15 * Ex: 'POST', 'GET'.
16 */
17 protected $method;
18
19 /**
20 * @var array
21 */
22 protected $fields;
23
24 /**
25 * RunControllerEvent constructor.
26 *
27 * @param \Civi\Setup\UI\SetupController $ctrl
28 * @param $method
29 * @param $fields
30 */
31 public function __construct($ctrl, $method, $fields) {
32 $this->ctrl = $ctrl;
33 $this->method = $method;
34 $this->fields = $fields;
35 }
36
37 /**
38 * @return \Civi\Setup\UI\SetupController
39 */
40 public function getCtrl() {
41 return $this->ctrl;
42 }
43
44 /**
45 * @return mixed
46 */
47 public function getMethod() {
48 return $this->method;
49 }
50
51 /**
52 * @return mixed
53 */
54 public function getFields() {
55 return $this->fields[\Civi\Setup\UI\SetupController::PREFIX];
56 }
57
58 public function getField($name, $default = NULL) {
59 if (isset($this->fields[\Civi\Setup\UI\SetupController::PREFIX][$name])) {
60 return $this->fields[\Civi\Setup\UI\SetupController::PREFIX][$name];
61 }
62 return $default;
63 }
64
65 /**
66 * @return \Civi\Setup\Model
67 */
68 public function getModel() {
69 return $this->ctrl->getSetup()->getModel();
70 }
71
72 }