Completed
Pull Request — master (#1703)
by Robbie
02:24
created

RedirectorPageController   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 1
dl 0
loc 25
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A init() 0 11 3
A Content() 0 6 1
1
<?php
2
namespace SilverStripe\CMS\Model;
3
4
use PageController;
5
6
/**
7
 * Controller for the {@link RedirectorPage}.
8
 */
9
class RedirectorPageController extends PageController
10
{
11
12
	public function init()
13
	{
14
		parent::init();
15
16
		// Check we don't already have a redirect code set
17
		/** @var RedirectorPage $page */
18
		$page = $this->data();
19
		if (!$this->getResponse()->isFinished() && $link = $page->redirectionLink()) {
20
			$this->redirect($link, 301);
21
		}
22
	}
23
24
	/**
25
	 * If we ever get this far, it means that the redirection failed.
26
	 */
27
	public function Content()
28
	{
29
		return "<p class=\"message-setupWithoutRedirect\">" .
30
		_t('RedirectorPage.HASBEENSETUP', 'A redirector page has been set up without anywhere to redirect to.') .
31
		"</p>";
32
	}
33
}
34