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

Handler   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 5
dl 0
loc 49
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getContents() 0 12 1
A handle() 0 21 3
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