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:
Sam Minnee 2012-03-16 14:16:07 +13:00
parent 6c35588eda
commit 8bbfa970d7
2 changed files with 7 additions and 10 deletions

View File

@ -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.

View File

@ -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'),
);
}
}