SiteTreeDataExtension   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 8
c 1
b 0
f 1
dl 0
loc 16
ccs 0
cts 6
cp 0
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A updateCMSFields() 0 7 2
1
<?php
2
3
namespace Dynamic\ShortURL\ORM;
4
5
use Dynamic\ShortURL\Model\ShortURL;
6
use SilverStripe\Forms\FieldList;
7
use SilverStripe\Forms\GridField\GridField;
8
use SilverStripe\Forms\GridField\GridFieldAddExistingAutocompleter;
9
use SilverStripe\Forms\GridField\GridFieldConfig_RelationEditor;
10
use SilverStripe\ORM\DataExtension;
11
use Symbiote\GridFieldExtensions\GridFieldAddExistingSearchButton;
0 ignored issues
show
Bug introduced by
The type Symbiote\GridFieldExtens...AddExistingSearchButton 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...
12
13
class SiteTreeDataExtension extends DataExtension
14
{
15
    /**
16
     * @var array
17
     */
18
    private static $many_many = [
0 ignored issues
show
introduced by
The private property $many_many is not used, and could be removed.
Loading history...
19
        'ShortURLs' => ShortURL::class,
20
    ];
21
22
    public function updateCMSFields(FieldList $fields)
23
    {
24
        if ($this->owner->ID) {
25
            $config = GridFieldConfig_RelationEditor::create()
26
                ->removeComponentsByType(GridFieldAddExistingAutocompleter::class);
27
            $urlsField = GridField::create('ShortURLs', 'Campaign URLs', $this->owner->ShortURLs(), $config);
28
            $fields->addFieldsToTab('Root.Share', $urlsField);
29
        }
30
    }
31
}
32