SubsiteAdmin   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 4
eloc 16
c 2
b 0
f 0
dl 0
loc 34
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getEditForm() 0 10 2
A canView() 0 6 2
1
<?php
2
3
namespace LeKoala\Admini\Subsites;
4
5
use LeKoala\Admini\ModelAdmin;
6
use LeKoala\Admini\MaterialIcons;
7
use SilverStripe\Subsites\Model\Subsite;
0 ignored issues
show
Bug introduced by
The type SilverStripe\Subsites\Model\Subsite was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
use SilverStripe\Subsites\State\SubsiteState;
0 ignored issues
show
Bug introduced by
The type SilverStripe\Subsites\State\SubsiteState was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
9
10
/**
11
 * Admin interface to manage and create {@link Subsite} instances.
12
 *
13
 * @package subsites
14
 */
15
class SubsiteAdmin extends ModelAdmin
16
{
17
    private static $managed_models = [Subsite::class];
0 ignored issues
show
introduced by
The private property $managed_models is not used, and could be removed.
Loading history...
18
19
    private static $url_segment = 'subsites';
20
21
    private static $menu_title = 'Subsites';
22
23
    private static $menu_icon = MaterialIcons::ACCOUNT_TREE;
0 ignored issues
show
introduced by
The private property $menu_icon is not used, and could be removed.
Loading history...
24
25
    public $showImportForm = false;
26
27
    private static $tree_class = Subsite::class;
28
29
    private static $required_permission_codes = "CMS_ACCESS_SilverStripe\Subsites\Admin\SubsiteAdmin"; // inherit SS permissions
30
31
    public function canView($member = null)
32
    {
33
        if (!class_exists(SubsiteState::class)) {
34
            return false;
35
        }
36
        return parent::canView($member);
37
    }
38
39
    public function getEditForm($id = null, $fields = null)
40
    {
41
        $form = parent::getEditForm($id, $fields);
42
43
        $grid = $form->Fields()->dataFieldByName(str_replace('\\', '-', Subsite::class));
44
        if ($grid) {
45
            $grid->setItemRequestClass(TabulatorSubsiteDetailFormItemRequest::class);
46
        }
47
48
        return $form;
49
    }
50
}
51