Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

API CHANGE: Remove Controller::Now(), as it was only ever a template …

…global provider, and use the new TemplateGlobalProvider interface on SS_Datetime instead.
  • Loading branch information...
commit 8bbfa970d7e699dac6e40b199b2fbbd4e95f4040 1 parent 6c35588
@sminnee sminnee authored
Showing with 7 additions and 10 deletions.
  1. +0 −9 control/Controller.php
  2. +7 −1 model/fieldtypes/Datetime.php
View
9 control/Controller.php
@@ -406,15 +406,6 @@ function can($perm, $member = null) {
//-----------------------------------------------------------------------------------
/**
- * 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
8 model/fieldtypes/Datetime.php
@@ -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 @@ static function set_mock_now($datetime) {
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'),
+ );
+ }
}
Please sign in to comment.
Something went wrong with that request. Please try again.