From 5ce3273ee52348781514b15d12f93c09a602689b Mon Sep 17 00:00:00 2001 From: Robert Curry Date: Thu, 28 Feb 2013 15:38:08 +1300 Subject: [PATCH] Add global option to enable or disable API --- _config.php | 3 +++ code/RestfulServer.php | 4 ++++ code/RestfulSiteConfig.php | 21 +++++++++++++++++++++ 3 files changed, 28 insertions(+) create mode 100644 code/RestfulSiteConfig.php diff --git a/_config.php b/_config.php index e69de29..f716afd 100644 --- a/_config.php +++ b/_config.php @@ -0,0 +1,3 @@ +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; diff --git a/code/RestfulSiteConfig.php b/code/RestfulSiteConfig.php new file mode 100644 index 0000000..eeca039 --- /dev/null +++ b/code/RestfulSiteConfig.php @@ -0,0 +1,21 @@ + array( + 'EnableRESTAPI' => 'Boolean' + ), + 'defaults' => array( + 'EnableRESTAPI' => false + ) + ); + } + + function updateCMSFields(FieldList $fields) { + $fields->addFieldToTab('Root.Main', new CheckboxField('EnableRESTAPI', 'Enable the REST API')); + } +}