This commit is contained in:
Robert Curry 2013-06-12 02:14:37 -07:00
commit 34e77df2a2
3 changed files with 28 additions and 0 deletions

View File

@ -0,0 +1,3 @@
<?php
Object::add_extension('SiteConfig', 'RestfulSiteConfig');

View File

@ -77,6 +77,10 @@ class RestfulServer extends Controller {
* Since no $Action url-param is set, all requests are sent here.
*/
function index() {
// if api is disabled globally, don't proceed
if (!SiteConfig::current_site_config()->EnableRESTAPI)
return $this->permissionFailure();
if(!isset($this->urlParams['ClassName'])) return $this->notFound();
$className = $this->urlParams['ClassName'];
$id = (isset($this->urlParams['ID'])) ? $this->urlParams['ID'] : null;

View File

@ -0,0 +1,21 @@
<?php
/**
* Adds new global settings.
*/
class RestfulSiteConfig extends DataExtension {
function extraStatics($class = null, $extension = null) {
return array(
'db' => array(
'EnableRESTAPI' => 'Boolean'
),
'defaults' => array(
'EnableRESTAPI' => false
)
);
}
function updateCMSFields(FieldList $fields) {
$fields->addFieldToTab('Root.Main', new CheckboxField('EnableRESTAPI', 'Enable the REST API'));
}
}