Options   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
dl 0
loc 58
rs 10
c 0
b 0
f 0
wmc 2
lcom 1
cbo 3

1 Method

Rating   Name   Duplication   Size   Complexity  
B delegate() 0 34 2
1
<?php
2
3
/**
4
 * Pattern for options action
5
 *
6
 * PHP Version 5
7
 *
8
 * @category  Core
9
 * @package   RAD
10
 * @author    Hans-Joachim Piepereit <[email protected]>
11
 * @copyright 2013 cSphere Team
12
 * @license   http://opensource.org/licenses/bsd-license Simplified BSD License
13
 * @link      http://www.csphere.eu
14
 **/
15
16
namespace csphere\core\rad;
17
18
/**
19
 * Pattern for options action
20
 *
21
 * @category  Core
22
 * @package   RAD
23
 * @author    Hans-Joachim Piepereit <[email protected]>
24
 * @copyright 2013 cSphere Team
25
 * @license   http://opensource.org/licenses/bsd-license Simplified BSD License
26
 * @link      http://www.csphere.eu
27
 **/
28
29
class Options extends \csphere\core\rad\Base
30
{
31
    /**
32
     * Action name
33
     **/
34
    protected $action = 'options';
35
36
    /**
37
     * Template file name
38
     **/
39
    protected $tpl = 'options';
40
41
    /**
42
     * Previous action
43
     **/
44
    protected $previous = 'manage';
45
46
    /**
47
     * Delegate action to run this method
48
     *
49
     * @return void
50
     **/
0 ignored issues
show
Coding Style introduced by
There must be no blank lines after the function comment
Loading history...
51
52
    public function delegate()
53
    {
54
        // Switch schema
55
        $this->schema = 'options';
56
57
        // Check for post data
58
        $post = \csphere\core\http\Input::getAll('post');
59
60
        // Get all options
61
        $dm_options = new \csphere\core\datamapper\Options($this->plugin);
62
        $options    = $dm_options->load();
63
64
        // Handle save requests
65
        if (isset($post['csphere_form'])) {
66
67
            // Fill post data into record
68
            $options = $this->form($options, $post);
69
70
            // Save all options
71
            $dm_options->save($options);
72
73
            $this->message('options_success', 0, 'green');
74
75
        } else {
76
77
            // Data array
78
            $data = [];
79
80
            $data['options'] = $options;
81
82
            // Send data to view
83
            $this->view($data);
84
        }
85
    }
86
}
87