silverstripe-webpack/app/src/Pages/PageController.php

40 lines
1.0 KiB
PHP
Raw Normal View History

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;
use SilverStripe\ORM\FieldType\DBDatetime;
2018-04-21 11:29:32 +07:00
class PageController extends ContentController
{
public static function setSiteWideMessage($message, $type, $request = null)
2018-08-06 18:46:54 +07:00
{
$request = $request ? $request : Controller::curr()->getRequest();
$request->getSession()->set(
2018-09-15 05:55:42 +07:00
'SiteWideMessage',
ArrayData::create([
2018-09-15 05:55:42 +07:00
'Message' => $message,
'Type' => $type,
])
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
{
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
return $this->site_message;
2018-08-06 18:46:54 +07:00
}
public function CurrentTime()
{
return DBDatetime::now();
}
2018-04-21 11:29:32 +07:00
}