FIX: Fixes #65 Use Injector to instantiate created objects.

This commit is contained in:
Russell Michell 2018-06-05 15:15:05 +12:00
parent 5b3f2f5c09
commit c9b7bc4169

View File

@ -15,6 +15,7 @@ use SilverStripe\ORM\ValidationResult;
use SilverStripe\Security\Member; use SilverStripe\Security\Member;
use SilverStripe\Security\Security; use SilverStripe\Security\Security;
use SilverStripe\CMS\Model\SiteTree; use SilverStripe\CMS\Model\SiteTree;
use SilverStripe\Core\Injector\Injector;
/** /**
* Generic RESTful server, which handles webservice access to arbitrary DataObjects. * Generic RESTful server, which handles webservice access to arbitrary DataObjects.
@ -553,7 +554,8 @@ class RestfulServer extends Controller
if (!singleton($className)->canCreate($this->getMember())) { if (!singleton($className)->canCreate($this->getMember())) {
return $this->permissionFailure(); return $this->permissionFailure();
} }
$obj = new $className();
$obj = Injector::inst()->create($className);
$reqFormatter = $this->getRequestDataFormatter($className); $reqFormatter = $this->getRequestDataFormatter($className);
if (!$reqFormatter) { if (!$reqFormatter) {