2018-04-21 11:29:32 +07:00
|
|
|
<?php
|
|
|
|
|
|
|
|
// vendor/silverstripe/errorpage/src/ErrorPageController.php
|
|
|
|
// extends global PageController class
|
|
|
|
//namespace Site\Pages;
|
|
|
|
|
|
|
|
use SilverStripe\CMS\Controllers\ContentController;
|
2018-07-02 08:54:18 +07:00
|
|
|
use SilverStripe\ORM\FieldType\DBDatetime;
|
2018-04-21 11:29:32 +07:00
|
|
|
|
|
|
|
class PageController extends ContentController
|
|
|
|
{
|
2018-12-05 14:16:26 +01:00
|
|
|
public static function setSiteWideMessage($message, $type, $request = null)
|
2018-08-06 18:46:54 +07:00
|
|
|
{
|
2018-12-05 14:16:26 +01:00
|
|
|
$request = $request ? $request : Controller::curr()->getRequest();
|
|
|
|
$request->getSession()->set(
|
2018-09-15 05:55:42 +07:00
|
|
|
'SiteWideMessage',
|
2018-12-05 14:16:26 +01:00
|
|
|
ArrayData::create([
|
2018-09-15 05:55:42 +07:00
|
|
|
'Message' => $message,
|
|
|
|
'Type' => $type,
|
2018-12-05 14:16:26 +01:00
|
|
|
])
|
2018-09-15 05:55:42 +07:00
|
|
|
);
|
2018-08-06 18:46:54 +07:00
|
|
|
}
|
|
|
|
|
2018-09-15 05:55:42 +07:00
|
|
|
public function getSiteWideMessage()
|
2018-08-06 18:46:54 +07:00
|
|
|
{
|
2018-12-05 14:16:26 +01:00
|
|
|
if (!$this->site_message) {
|
|
|
|
$session = $this->getRequest()->getSession();
|
|
|
|
$this->site_message = $session->get('SiteWideMessage');
|
|
|
|
$session->clear('SiteWideMessage');
|
|
|
|
}
|
2018-09-15 05:55:42 +07:00
|
|
|
|
2018-12-05 14:16:26 +01:00
|
|
|
return $this->site_message;
|
2018-08-06 18:46:54 +07:00
|
|
|
}
|
|
|
|
|
2018-07-02 08:54:18 +07:00
|
|
|
public function CurrentTime()
|
|
|
|
{
|
|
|
|
return DBDatetime::now();
|
|
|
|
}
|
2018-04-21 11:29:32 +07:00
|
|
|
}
|