2012-04-30 15:04:59 +02:00
|
|
|
<?php
|
2016-08-19 10:51:35 +12:00
|
|
|
|
|
|
|
use SilverStripe\Core\Injector\Injector;
|
2016-09-09 18:43:05 +12:00
|
|
|
use SilverStripe\Control\HTTPRequest;
|
|
|
|
use SilverStripe\Control\HTTPResponse;
|
2016-08-19 10:51:35 +12:00
|
|
|
use SilverStripe\Control\Controller;
|
|
|
|
|
2012-04-30 15:04:59 +02:00
|
|
|
// Fake a current controller. Way harder than it should be
|
|
|
|
class FakeController extends Controller {
|
2014-08-15 18:53:05 +12:00
|
|
|
|
2012-09-19 12:07:39 +02:00
|
|
|
public function __construct() {
|
2012-04-30 15:04:59 +02:00
|
|
|
parent::__construct();
|
|
|
|
|
2016-08-19 10:51:35 +12:00
|
|
|
$session = Injector::inst()->create('SilverStripe\\Control\\Session', isset($_SESSION) ? $_SESSION : array());
|
2012-04-30 15:04:59 +02:00
|
|
|
$this->setSession($session);
|
2014-08-15 18:53:05 +12:00
|
|
|
|
2012-04-30 15:04:59 +02:00
|
|
|
$this->pushCurrent();
|
|
|
|
|
2016-09-09 18:43:05 +12:00
|
|
|
$request = new HTTPRequest(
|
2014-08-15 18:53:05 +12:00
|
|
|
(isset($_SERVER['X-HTTP-Method-Override']))
|
|
|
|
? $_SERVER['X-HTTP-Method-Override']
|
2012-09-27 09:34:00 +12:00
|
|
|
: $_SERVER['REQUEST_METHOD'],
|
2012-04-30 15:04:59 +02:00
|
|
|
'/'
|
|
|
|
);
|
2015-04-30 11:04:08 +12:00
|
|
|
$this->setRequest($request);
|
2015-08-14 12:39:33 +12:00
|
|
|
|
2016-09-09 18:43:05 +12:00
|
|
|
$this->setResponse(new HTTPResponse());
|
2014-08-15 18:53:05 +12:00
|
|
|
|
2015-02-23 13:46:00 +00:00
|
|
|
$this->doInit();
|
2012-04-30 15:04:59 +02:00
|
|
|
}
|
2014-06-19 10:38:26 +12:00
|
|
|
}
|