mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
085346f0e0
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@69704 467b73ca-7a2a-4603-9d3b-597d59a354a9
134 lines
3.4 KiB
PHP
134 lines
3.4 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Base class for URL access to development tools. Currently supports the
|
|
* ; and TaskRunner.
|
|
*
|
|
* @todo documentation for how to add new unit tests and tasks
|
|
* @package sapphire
|
|
* @subpackage dev
|
|
*/
|
|
class DevelopmentAdmin extends Controller {
|
|
|
|
static $url_handlers = array(
|
|
'' => 'index',
|
|
'$Action' => '$Action',
|
|
'$Action//$Action/$ID' => 'handleAction',
|
|
);
|
|
|
|
|
|
function init() {
|
|
parent::init();
|
|
|
|
// check for valid url mapping
|
|
// lacking this information can cause really nasty bugs,
|
|
// e.g. when running Director::test() from a FunctionalTest instance
|
|
global $_FILE_TO_URL_MAPPING;
|
|
if(Director::is_cli()) {
|
|
if(isset($_FILE_TO_URL_MAPPING)) {
|
|
$fullPath = $testPath = $_SERVER['SCRIPT_FILENAME'];
|
|
while($testPath && $testPath != "/") {
|
|
$matched = false;
|
|
if(isset($_FILE_TO_URL_MAPPING[$testPath])) {
|
|
$matched = true;
|
|
break;
|
|
}
|
|
$testPath = dirname($testPath);
|
|
}
|
|
if(!$matched) {
|
|
echo 'Warning: You probably want to define '.
|
|
'an entry in $_FILE_TO_URL_MAPPING that covers "' . Director::baseFolder() . '"' . "\n";
|
|
}
|
|
}
|
|
else {
|
|
echo 'Warning: You probably want to define $_FILE_TO_URL_MAPPING in '.
|
|
'your _ss_environment.php as instructed on the "sake" page of the doc.silverstripe.com wiki' . "\n";
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
function index() {
|
|
$actions = array(
|
|
"build" => "Build/rebuild this environment (formerly db/build). 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",
|
|
"modules/add" => "Add a module, for example, 'sake dev/modules/add ecommerce'",
|
|
"tasks" => "See a list of build tasks to run",
|
|
"viewcode" => "Read source code in a literate programming style",
|
|
);
|
|
|
|
// Web mode
|
|
if(!Director::is_cli()) {
|
|
// This action is sake-only right now.
|
|
unset($actions["modules/add"]);
|
|
|
|
$renderer = new DebugView();
|
|
$renderer->writeHeader();
|
|
$renderer->writeInfo("Sapphire Development Tools", Director::absoluteBaseURL());
|
|
$base = Director::baseURL();
|
|
|
|
echo '<div class="options"><ul>';
|
|
foreach($actions as $action => $description) {
|
|
echo "<li><a href=\"{$base}dev/$action\"><b>/dev/$action:</b> $description</a></li>\n";
|
|
}
|
|
|
|
$renderer->writeFooter();
|
|
|
|
// CLI mode
|
|
} else {
|
|
echo "SAPPHIRE DEVELOPMENT TOOLS\n--------------------------\n\n";
|
|
echo "You can execute any of the following commands:\n\n";
|
|
foreach($actions as $action => $description) {
|
|
echo " sake dev/$action: $description\n";
|
|
}
|
|
echo "\n\n";
|
|
}
|
|
}
|
|
|
|
function tests($request) {
|
|
return new TestRunner();
|
|
}
|
|
|
|
function jstests($request) {
|
|
return new JSTestRunner();
|
|
}
|
|
|
|
function tasks() {
|
|
return new TaskRunner();
|
|
}
|
|
|
|
function modules() {
|
|
return new ModuleManager();
|
|
}
|
|
|
|
function viewmodel() {
|
|
return new ModelViewer();
|
|
}
|
|
|
|
function build() {
|
|
$renderer = new DebugView();
|
|
$renderer->writeHeader();
|
|
$renderer->writeInfo("Environment Builder (formerly db/build)", Director::absoluteBaseURL());
|
|
echo "<div style=\"margin: 0 2em\">";
|
|
|
|
$da = new DatabaseAdmin();
|
|
$da->build();
|
|
|
|
echo "</div>";
|
|
$renderer->writeFooter();
|
|
}
|
|
|
|
function errors() {
|
|
Director::redirect("Debug_");
|
|
}
|
|
|
|
function viewcode($request) {
|
|
return new CodeViewer();
|
|
}
|
|
}
|
|
|
|
?>
|