mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
API CHANGE: Remove Controller::Now(), as it was only ever a template global provider, and use the new TemplateGlobalProvider interface on SS_Datetime instead.
This commit is contained in:
parent
6c35588eda
commit
8bbfa970d7
@ -406,15 +406,6 @@ class Controller extends RequestHandler implements TemplateGlobalProvider {
|
||||
//-----------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* returns a date object for use within a template
|
||||
* Usage: $Now.Year - Returns 2006
|
||||
* @return Date The current date
|
||||
*/
|
||||
function Now() {
|
||||
$d = new Date(null);
|
||||
$d->setValue(date("Y-m-d h:i:s"));
|
||||
return $d;
|
||||
}
|
||||
* Pushes this controller onto the stack of current controllers.
|
||||
* This means that any redirection, session setting, or other things that rely on Controller::curr() will now write to this
|
||||
* controller object.
|
||||
|
@ -23,7 +23,7 @@
|
||||
* @package sapphire
|
||||
* @subpackage model
|
||||
*/
|
||||
class SS_Datetime extends Date {
|
||||
class SS_Datetime extends Date implements TemplateGlobalProvider {
|
||||
|
||||
function setValue($value) {
|
||||
if($value === false || $value === null || (is_string($value) && !strlen($value))) {
|
||||
@ -124,5 +124,11 @@ class SS_Datetime extends Date {
|
||||
static function clear_mock_now() {
|
||||
self::$mock_now = null;
|
||||
}
|
||||
|
||||
public static function get_template_global_variables() {
|
||||
return array(
|
||||
'Now' => array('method' => 'now', 'casting' => 'SS_Datetime'),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user