1 | <?php |
||
18 | class Settings extends Controller |
||
19 | { |
||
20 | |||
21 | /** |
||
22 | * Order model instance |
||
23 | * @var \gplcart\core\models\Order $order |
||
24 | */ |
||
25 | protected $order; |
||
26 | |||
27 | /** |
||
28 | * @param Order $order |
||
29 | */ |
||
30 | public function __construct(Order $order) |
||
31 | { |
||
32 | parent::__construct(); |
||
33 | |||
34 | $this->order = $order; |
||
35 | } |
||
36 | |||
37 | /** |
||
38 | * Route page callback to display module settings form |
||
39 | */ |
||
40 | public function editSettings() |
||
41 | { |
||
42 | $this->setTitleEditSettings(); |
||
43 | $this->setBreadcrumbEditSettings(); |
||
44 | |||
45 | $this->setData('statuses', $this->order->getStatuses()); |
||
46 | $this->setData('settings', $this->module->getSettings('authorize')); |
||
47 | |||
48 | $this->submitSettings(); |
||
49 | $this->outputEditSettings(); |
||
50 | } |
||
51 | |||
52 | /** |
||
53 | * Saves the submitted settings |
||
54 | */ |
||
55 | protected function submitSettings() |
||
56 | { |
||
57 | if ($this->isPosted('save') && $this->validateSettings()) { |
||
58 | $this->updateSettings(); |
||
59 | } |
||
60 | } |
||
61 | |||
62 | /** |
||
63 | * Updates module settings |
||
64 | */ |
||
65 | protected function updateSettings() |
||
71 | |||
72 | /** |
||
73 | * Validates module settings |
||
74 | * @return bool |
||
75 | */ |
||
76 | protected function validateSettings() |
||
77 | { |
||
78 | $this->setSubmitted('settings'); |
||
79 | $this->setSubmittedBool('status'); |
||
80 | |||
81 | return !$this->hasErrors('settings'); |
||
82 | } |
||
83 | |||
84 | /** |
||
85 | * Set title on the edit module settings page |
||
86 | */ |
||
87 | protected function setTitleEditSettings() |
||
88 | { |
||
89 | $title = $this->text('Edit %name settings', array('%name' => $this->text('Authorize'))); |
||
90 | $this->setTitle($title); |
||
91 | } |
||
92 | |||
93 | /** |
||
94 | * Set breadcrumbs on the edit module settings page |
||
95 | */ |
||
96 | protected function setBreadcrumbEditSettings() |
||
112 | |||
113 | /** |
||
114 | * Render and output the edit module settings page |
||
115 | */ |
||
116 | protected function outputEditSettings() |
||
120 | |||
121 | } |
||
122 |