CwpSearchPageController::generateSearchRecord()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 7
rs 10
cc 1
nc 1
nop 0
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