AddonsController   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A index() 0 10 2
A edit() 0 10 2
1
<?php namespace Anomaly\PreferencesModule\Http\Controller\Admin;
2
3
use Anomaly\PreferencesModule\Preference\Form\PreferenceFormBuilder;
4
use Anomaly\PreferencesModule\Preference\Table\AddonTableBuilder;
5
use Anomaly\Streams\Platform\Http\Controller\AdminController;
6
use Anomaly\Streams\Platform\Support\Authorizer;
7
8
/**
9
 * Class AddonsController
10
 *
11
 * @link          http://pyrocms.com/
12
 * @author        PyroCMS, Inc. <[email protected]>
13
 * @author        Ryan Thompson <[email protected]>
14
 */
15
class AddonsController extends AdminController
16
{
17
18
    /**
19
     * Return an index of addons with preferences.
20
     *
21
     * @param  AddonTableBuilder                          $table
22
     * @param  Authorizer                                 $authorizer
23
     * @param                                             $type
24
     * @return \Symfony\Component\HttpFoundation\Response
25
     */
26
    public function index(AddonTableBuilder $table, Authorizer $authorizer, $type)
27
    {
28
        if (!$authorizer->authorize('anomaly.module.preferences::preferences.write')) {
29
            abort(403);
30
        }
31
32
        $table->setType($type);
33
34
        return $table->render();
35
    }
36
37
    /**
38
     * Return a form for editing preferences.
39
     *
40
     * @param  PreferenceFormBuilder                      $form
41
     * @param  Authorizer                                 $authorizer
42
     * @param                                             $type
43
     * @param                                             $addon
44
     * @return \Symfony\Component\HttpFoundation\Response
45
     */
46
    public function edit(PreferenceFormBuilder $form, Authorizer $authorizer, $type, $addon)
47
    {
48
        if (!$authorizer->authorize('anomaly.module.preferences::preferences.write')) {
49
            abort(403);
50
        }
51
52
        unset($type);
53
54
        return $form->render($addon);
55
    }
56
}
57