Passed
Push — master ( 19e85c...7a6648 )
by Nicolaas
10:46
created

QuickSearchController::Link()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 1
b 0
f 0
1
<?php
2
3
namespace Sunnysideup\SiteWideSearch\Control;
4
5
use SilverStripe\Control\Controller;
6
7
use SilverStripe\CMS\Model\SiteTree;
8
use SilverStripe\Core\ClassInfo;
9
use SilverStripe\Core\Config\Configurable;
10
use SilverStripe\Forms\FieldList;
11
use SilverStripe\Forms\Form;
12
use SilverStripe\Forms\FormAction;
13
use SilverStripe\Forms\TextField;
14
use SilverStripe\ORM\DataObject;
15
use Sunnysideup\SiteWideSearch\Interfaces\QuickSearchInterface;
16
17
class QuickSearchController extends Controller
18
{
19
    private static $url_segment = 'admin/quicksearch';
20
21
    private static $allowed_actions = [
22
        'index' => 'ADMIN',
23
        'getform' => 'ADMIN',
24
        'doform' => 'ADMIN',
25
    ];
26
27
    public function Link($action = '')
28
    {
29
        return '/' . $this->Config()->get('url_segment') . '/' . $action;
30
    }
31
32
33
    public function FormProvider(): Form
34
    {
35
        $form = new Form(
36
            $this,
37
            'FormProvider',
38
            FieldList::create(
39
                TextField::create('Keywords', 'Keyword(s)', $this->getKeywords() ?? '')
40
                    ->setAttribute('placeholder', 'e.g. agreement')
41
            ),
42
            FieldList::create(
43
                FormAction::create('doSearch', 'Search')
44
            )
45
        );
46
        $form->setFormMethod('GET');
47
        $form->setFormAction($this->Link());
48
        $form->disableSecurityToken();
49
        return $form;
50
    }
51
52
    public function FormProcessor(Form $form, array $data): array
0 ignored issues
show
Unused Code introduced by
The parameter $data is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

52
    public function FormProcessor(Form $form, /** @scrutinizer ignore-unused */ array $data): array

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $form is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

52
    public function FormProcessor(/** @scrutinizer ignore-unused */ Form $form, array $data): array

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
53
    {
54
        return [];
55
    }
56
    public function getKeywords()
57
    {
58
        return '';
59
    }
60
}
61