CwpSearchPageController   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 10
c 1
b 0
f 0
dl 0
loc 27
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A index() 0 3 1
A generateSearchRecord() 0 7 1
A __construct() 0 6 2
1
<?php
2
3
namespace CWP\Search;
4
5
use PageController;
0 ignored issues
show
Bug introduced by
The type PageController 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...
6
7
/**
8
 * Description of SearchPageController
9
 *
10
 * @author dmooyman
11
 */
12
class CwpSearchPageController extends PageController
13
{
14
    /**
15
     * Create the dummy search record for this page
16
     *
17
     * @return CwpSearchPage
18
     */
19
    protected function generateSearchRecord()
20
    {
21
        $searchPage = CwpSearchPage::create();
22
        $searchPage->URLSegment = 'search';
23
        $searchPage->Title = _t('SilverStripe\\CMS\\Search\\SearchForm.SearchResults', 'Search Results');
24
        $searchPage->ID = -1;
25
        return $searchPage;
26
    }
27
28
    public function __construct($dataRecord = null)
29
    {
30
        if (!$dataRecord) {
31
            $dataRecord = $this->generateSearchRecord();
32
        }
33
        parent::__construct($dataRecord);
34
    }
35
36
    public function index()
37
    {
38
        return $this->redirect($this->Link('SearchForm'));
39
    }
40
}
41