From 9e923d6f9e33c5ff07f5144daa46e0dcb720e159 Mon Sep 17 00:00:00 2001 From: Russ Michell Date: Wed, 6 Jun 2018 09:39:30 +1200 Subject: [PATCH] FIX: Fixes #65 Use Injector to instantiate created objects. (#68) --- src/RestfulServer.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/RestfulServer.php b/src/RestfulServer.php index 8212daf..38da66f 100644 --- a/src/RestfulServer.php +++ b/src/RestfulServer.php @@ -15,6 +15,7 @@ use SilverStripe\ORM\ValidationResult; use SilverStripe\Security\Member; use SilverStripe\Security\Security; use SilverStripe\CMS\Model\SiteTree; +use SilverStripe\Core\Injector\Injector; /** * Generic RESTful server, which handles webservice access to arbitrary DataObjects. @@ -523,7 +524,8 @@ class RestfulServer extends Controller if (!singleton($className)->canCreate($this->getMember())) { return $this->permissionFailure(); } - $obj = new $className(); + + $obj = Injector::inst()->create($className); $reqFormatter = $this->getRequestDataFormatter($className); if (!$reqFormatter) {