Completed
Push — master ( cab21e...ed90cc )
by Daniel
02:43
created

RedirectorPageController::init()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 11
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 11
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 5
nc 2
nop 0
1
<?php
2
namespace SilverStripe\CMS\Model;
3
4
use SilverStripe\Control\HTTPRequest;
5
use PageController;
6
7
/**
8
 * Controller for the {@link RedirectorPage}.
9
 */
10
class RedirectorPageController extends PageController
11
{
12
    private static $allowed_actions = ['index'];
13
14
    /**
15
     * Check we don't already have a redirect code set
16
     *
17
     * @param  HTTPRequest $request
18
     * @return \SilverStripe\Control\HTTPResponse
19
     */
20
    public function index(HTTPRequest $request)
21
    {
22
        /** @var RedirectorPage $page */
23
        $page = $this->data();
24
        if (!$this->getResponse()->isFinished() && $link = $page->redirectionLink()) {
25
            $this->redirect($link, 301);
26
        }
27
        return parent::handleAction($request, 'handleIndex');
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (handleAction() instead of index()). Are you sure this is correct? If so, you might want to change this to $this->handleAction().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
28
    }
29
30
    /**
31
     * If we ever get this far, it means that the redirection failed.
32
     */
33
    public function getContent()
34
    {
35
        return "<p class=\"message-setupWithoutRedirect\">" .
36
        _t(__CLASS__ . '.HASBEENSETUP', 'A redirector page has been set up without anywhere to redirect to.') .
37
        "</p>";
38
    }
39
}
40