silverstripe-cms/code/Model/RedirectorPageController.php

34 lines
858 B
PHP
Raw Normal View History

<?php
namespace SilverStripe\CMS\Model;
use PageController;
/**
* Controller for the {@link RedirectorPage}.
*/
class RedirectorPageController extends PageController
{
2017-01-25 21:59:25 +01:00
protected function init()
{
parent::init();
2017-01-25 21:59:25 +01:00
// Check we don't already have a redirect code set
/** @var RedirectorPage $page */
$page = $this->data();
if (!$this->getResponse()->isFinished() && $link = $page->redirectionLink()) {
$this->redirect($link, 301);
}
}
2017-01-25 21:59:25 +01:00
/**
* If we ever get this far, it means that the redirection failed.
*/
public function Content()
{
return "<p class=\"message-setupWithoutRedirect\">" .
2017-04-20 03:15:29 +02:00
_t('SilverStripe\\CMS\\Model\\RedirectorPage.HASBEENSETUP', 'A redirector page has been set up without anywhere to redirect to.') .
2017-01-25 21:59:25 +01:00
"</p>";
}
}