Passed
Pull Request — master (#15)
by Anton
03:07
created

Handler::getContents()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 12
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 0
1
<?php
2
3
/**
4
 * @package Cadmium\System\Modules\Settings
5
 * @author Anton Romanov
6
 * @copyright Copyright (c) 2015-2017, Anton Romanov
7
 * @link http://cadmium-cms.com
8
 */
9
10
namespace Modules\Settings\Utils {
11
12
	use Frames, Utils\Popup, Utils\View, Language, Request, Template;
13
14
	abstract class Handler extends Frames\Admin\Area\Panel {
15
16
		protected $_title = 'TITLE_SYSTEM_SETTINGS';
17
18
		private $form = null;
19
20
		/**
21
		 * Get the contents block
22
		 */
23
24
		private function getContents() : Template\Block {
25
26
			$contents = View::get(static::$view);
27
28
			# Implement form
29
30
			$this->form->implement($contents);
31
32
			# ------------------------
33
34
			return $contents;
35
		}
36
37
		/**
38
		 * Handle the request
39
		 */
40
41
		protected function handle() : Template\Block {
42
43
			# Create form
44
45
			$this->form = new static::$form_class;
46
47
			# Handle form
48
49
			if ($this->form->handle(new static::$controller_class, true)) {
50
51
				Request::redirect(INSTALL_PATH . (static::$url . '?submitted'));
52
			}
53
54
			# Display success message
55
56
			if (false !== Request::get('submitted')) Popup::set('positive', Language::get('SETTINGS_SUCCESS'));
57
58
			# ------------------------
59
60
			return $this->getContents();
61
		}
62
	}
63
}
64