From b3d52de53111bc302d12f78f5cc75d04065f5d99 Mon Sep 17 00:00:00 2001 From: Igor Nadj Date: Wed, 6 Aug 2014 16:29:52 +1200 Subject: [PATCH] ENH making /dev extendable --- _config/dev.yml | 23 +++++ dev/DevBuildController.php | 32 +++++++ dev/DevelopmentAdmin.php | 126 ++++++++++++++++----------- tests/dev/DevAdminControllerTest.php | 116 ++++++++++++++++++++++++ 4 files changed, 244 insertions(+), 53 deletions(-) create mode 100644 _config/dev.yml create mode 100644 dev/DevBuildController.php create mode 100644 tests/dev/DevAdminControllerTest.php diff --git a/_config/dev.yml b/_config/dev.yml new file mode 100644 index 000000000..a3aa0b604 --- /dev/null +++ b/_config/dev.yml @@ -0,0 +1,23 @@ +--- +Name: DevelopmentAdmin +--- +DevelopmentAdmin: + registered_controllers: + build: + controller: 'DevBuildController' + links: + build: 'Build/rebuild this environment. Call this whenever you have updated your project sources' + tests: + controller: 'TestRunner' + links: + tests: 'See a list of unit tests to run' + 'tests/all': 'Run all tests' + jstests: + controller: 'JSTestRunner' + links: + jstests: 'See a list of JavaScript tests to run' + 'jstests/all': 'Run all JavaScript tests' + tasks: + controller: 'TaskRunner' + links: + tasks: 'See a list of build tasks to run' \ No newline at end of file diff --git a/dev/DevBuildController.php b/dev/DevBuildController.php new file mode 100644 index 000000000..02ffbaa52 --- /dev/null +++ b/dev/DevBuildController.php @@ -0,0 +1,32 @@ + 'build' + ); + + private static $allowed_actions = array( + 'build' + ); + + + public function build($request) { + if(Director::is_cli()) { + $da = DatabaseAdmin::create(); + return $da->handleRequest($request, $this->model); + } else { + $renderer = DebugView::create(); + $renderer->writeHeader(); + $renderer->writeInfo("Environment Builder", Director::absoluteBaseURL()); + echo "
"; + + $da = DatabaseAdmin::create(); + return $da->handleRequest($request, $this->model); + + echo "
"; + $renderer->writeFooter(); + } + } + +} diff --git a/dev/DevelopmentAdmin.php b/dev/DevelopmentAdmin.php index 6533aea10..d68d941f7 100644 --- a/dev/DevelopmentAdmin.php +++ b/dev/DevelopmentAdmin.php @@ -1,10 +1,15 @@ 'index', 'build/defaults' => 'buildDefaults', - '$Action' => '$Action', - '$Action//$Action/$ID' => 'handleAction', + 'generatesecuretoken' => 'generatesecuretoken', + '$Action' => 'runRegisteredController', ); private static $allowed_actions = array( 'index', - 'tests', - 'jstests', - 'tasks', - 'viewmodel', - 'build', - 'reset', - 'viewcode', - 'generatesecuretoken', 'buildDefaults', + 'runRegisteredController', + 'generatesecuretoken', ); + public function init() { parent::init(); @@ -80,20 +80,8 @@ class DevelopmentAdmin extends Controller { } public function index() { - $actions = array( - "build" => "Build/rebuild this environment. Call this whenever you have updated your project sources", - "tests" => "See a list of unit tests to run", - "tests/all" => "Run all tests", - "jstests" => "See a list of JavaScript tests to run", - "jstests/all" => "Run all JavaScript tests", - "tasks" => "See a list of build tasks to run" - ); - // Web mode if(!Director::is_cli()) { - // This action is sake-only right now. - unset($actions["modules/add"]); - $renderer = DebugView::create(); $renderer->writeHeader(); $renderer->writeInfo("SilverStripe Development Tools", Director::absoluteBaseURL()); @@ -101,7 +89,7 @@ class DevelopmentAdmin extends Controller { echo '