From af652463f17d3c04a069ba971b04a436a8af585c Mon Sep 17 00:00:00 2001 From: Hamish Friedlander Date: Fri, 5 Jul 2013 09:58:39 +1200 Subject: [PATCH] FIX Defaulting to stage mode If you exposed Page instances through RestfulServer, the default Versioned stage would be Stage, rather than Live. --- code/RestfulServer.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/code/RestfulServer.php b/code/RestfulServer.php index c5ad885..4ecb8de 100644 --- a/code/RestfulServer.php +++ b/code/RestfulServer.php @@ -71,7 +71,16 @@ class RestfulServer extends Controller { return new RestfulServer_List(DataObject::get($request->param("ClassName"),"")); } */ - + + function init() { + /* This sets up SiteTree the same as when viewing a page through the frontend. Versioned defaults + * to Stage, and then when viewing the front-end Versioned::choose_site_stage changes it to Live. + * TODO: In 3.2 we should make the default Live, then change to Stage in the admin area (with a nicer API) + */ + if (class_exists('SiteTree')) singleton('SiteTree')->extend('modelascontrollerInit', $this); + parent::init(); + } + /** * This handler acts as the switchboard for the controller. * Since no $Action url-param is set, all requests are sent here.