From c9b7bc416964ed732f3405050967559b759faa5f Mon Sep 17 00:00:00 2001 From: Russell Michell Date: Tue, 5 Jun 2018 15:15:05 +1200 Subject: [PATCH] FIX: Fixes #65 Use Injector to instantiate created objects. --- src/RestfulServer.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/RestfulServer.php b/src/RestfulServer.php index 69a60e0..d4c1b06 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. @@ -553,7 +554,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) {