Webylon 3.2 API Docs
  • Package
  • Class
  • Tree
  • Deprecated
  • Download
Version: current
  • 3.2
  • 3.1

Packages

  • 1c
    • exchange
      • catalog
  • auth
  • Booking
  • building
    • company
  • cart
    • shipping
    • steppedcheckout
  • Catalog
    • monument
  • cms
    • assets
    • batchaction
    • batchactions
    • bulkloading
    • comments
    • content
    • core
    • export
    • newsletter
    • publishers
    • reports
    • security
    • tasks
  • Dashboard
  • DataObjectManager
  • event
  • faq
  • forms
    • actions
    • core
    • fields-basic
    • fields-dataless
    • fields-datetime
    • fields-files
    • fields-formatted
    • fields-formattedinput
    • fields-relational
    • fields-structural
    • transformations
    • validators
  • googlesitemaps
  • guestbook
  • installer
  • newsletter
  • None
  • photo
    • gallery
  • PHP
  • polls
  • recaptcha
  • sapphire
    • api
    • bulkloading
    • control
    • core
    • cron
    • dev
    • email
    • fields-formattedinput
    • filesystem
    • formatters
    • forms
    • i18n
    • integration
    • misc
    • model
    • parsers
    • search
    • security
    • tasks
    • testing
    • tools
    • validation
    • view
    • widgets
  • seo
    • open
      • graph
  • sfDateTimePlugin
  • spamprotection
  • stealth
    • captha
  • subsites
  • userform
    • pagetypes
  • userforms
  • webylon
  • widgets

Classes

  • BuildTask
  • CliDebugView
  • ConvertFrom26Task
  • Debug
  • DebugView
  • DeleteUnusedCustomerFilesTask
  • DevelopmentAdmin
  • FillLinkTrackingTask
  • FillOldLogDataTask
  • FindBadLinksTask
  • ImportTestContentTask
  • MigrationTask
  • MySQLDatabaseConfigurationHelper
  • PhotoGalleryMigrationTask
  • SapphireREPL
  • SS_Backtrace
  • SS_Cli
  • SS_Log
  • SS_LogEmailWriter
  • SS_LogErrorEmailFormatter
  • SS_LogErrorFileFormatter
  • SS_LogFileWriter
  • SS_ZendLog
  • TaskRunner
  1 <?php
  2 
  3 /**
  4  * Base class for URL access to development tools. Currently supports the
  5  * ; and TaskRunner.
  6  *
  7  * @todo documentation for how to add new unit tests and tasks
  8  * @package sapphire
  9  * @subpackage dev
 10  */
 11 class DevelopmentAdmin extends Controller {
 12     
 13     static $url_handlers = array(
 14         '' => 'index',
 15         '$Action' => '$Action',
 16         '$Action//$Action/$ID' => 'handleAction',
 17     );
 18     
 19     function init() {
 20         parent::init();
 21         
 22         // We allow access to this controller regardless of live-status or ADMIN permission only
 23         // if on CLI.  Access to this controller is always allowed in "dev-mode", or of the user is ADMIN.
 24         $canAccess = (Director::isDev() || Director::is_cli() || Permission::check("ADMIN"));
 25         // Special case for dev/build: Allow unauthenticated building of database, emulate DatabaseAdmin->init()
 26         // permission restrictions (see #4957)
 27         // TODO Decouple sub-controllers like DatabaseAdmin instead of weak URL checking
 28         $requestedDevBuild = (stripos($this->request->getURL(), 'dev/build') === 0 && !Security::database_is_ready());
 29         
 30         if(!$canAccess && !$requestedDevBuild) {
 31             return Security::permissionFailure($this);
 32         }
 33         
 34         // check for valid url mapping
 35         // lacking this information can cause really nasty bugs,
 36         // e.g. when running Director::test() from a FunctionalTest instance
 37         global $_FILE_TO_URL_MAPPING;
 38         if(Director::is_cli()) {
 39             if(isset($_FILE_TO_URL_MAPPING)) {
 40                 $fullPath = $testPath = BASE_PATH;
 41                 while($testPath && $testPath != "/" && !preg_match('/^[A-Z]:\\\\$/', $testPath)) {
 42                     $matched = false;
 43                     if(isset($_FILE_TO_URL_MAPPING[$testPath])) {
 44                         $matched = true;
 45                         break;
 46                     }
 47                     $testPath = dirname($testPath);
 48                 }
 49                 if(!$matched) {
 50                     echo 'Warning: You probably want to define '.
 51                         'an entry in $_FILE_TO_URL_MAPPING that covers "' . Director::baseFolder() . '"' . "\n";
 52                 }
 53             }
 54             else {
 55                 echo 'Warning: You probably want to define $_FILE_TO_URL_MAPPING in '.
 56                     'your _ss_environment.php as instructed on the "sake" page of the doc.silverstripe.org wiki' . "\n";
 57             }
 58         }
 59         
 60     }
 61     
 62     function index() {
 63         $actions = array(
 64             "build" => "Build/rebuild this environment (formerly db/build).  Call this whenever you have updated your project sources",
 65             "buildcache" => "Rebuild the static cache, if you're using StaticPublisher",
 66             "tests" => "See a list of unit tests to run",
 67             "tests/all" => "Run all tests",
 68             "tests/startsession" => "Start a test session in your browser (gives you a temporary database with default content)",
 69             "tests/endsession" => "Ends a test session",
 70             "jstests" => "See a list of JavaScript tests to run",
 71             "jstests/all" => "Run all JavaScript tests",
 72             "tasks" => "See a list of build tasks to run",
 73             "viewcode" => "Read source code in a literate programming style",
 74         );
 75         
 76         // Web mode
 77         if(!Director::is_cli()) {
 78             // This action is sake-only right now.
 79             unset($actions["modules/add"]);
 80             
 81             $renderer = new DebugView();
 82             $renderer->writeHeader();
 83             $renderer->writeInfo("Sapphire Development Tools", Director::absoluteBaseURL());
 84             $base = Director::baseURL();
 85 
 86             echo '<div class="options"><ul>';
 87             foreach($actions as $action => $description) {
 88                 echo "<li><a href=\"{$base}dev/$action\"><b>/dev/$action:</b> $description</a></li>\n";
 89             }
 90 
 91             $renderer->writeFooter();
 92         
 93         // CLI mode
 94         } else {
 95             echo "SAPPHIRE DEVELOPMENT TOOLS\n--------------------------\n\n";
 96             echo "You can execute any of the following commands:\n\n";
 97             foreach($actions as $action => $description) {
 98                 echo "  sake dev/$action: $description\n";
 99             }
100             echo "\n\n";
101         }
102     }
103     
104     function tests($request) {
105         return new TestRunner();
106     }
107     
108     function jstests($request) {
109         return new JSTestRunner();
110     }
111     
112     function tasks() {
113         return new TaskRunner();
114     }
115     
116     function viewmodel() {
117         return new ModelViewer();
118     }
119     
120     function build() {
121         if(Director::is_cli()) {
122             $da = new DatabaseAdmin();
123             $da->build();
124         } else {
125             $renderer = new DebugView();
126             $renderer->writeHeader();
127             $renderer->writeInfo("Environment Builder (formerly db/build)", Director::absoluteBaseURL());
128             echo "<div style=\"margin: 0 2em\">";
129 
130             $da = new DatabaseAdmin();
131             $da->build();
132 
133             echo "</div>";
134             $renderer->writeFooter();
135         }
136     }
137     
138     function reset() {
139         $link = BASE_URL.'/dev/tests/startsession';
140         
141         return "<p>The dev/reset feature has been removed.  If you are trying to test your site " .
142             "with a clean datababase, we recommend that you use " .
143             "<a href=\"$link\">dev/test/startsession</a> ".
144             "instead.</P>";
145 
146     }
147     
148     function errors() {
149         Director::redirect("Debug_");
150     }
151     
152     function viewcode($request) {
153         return new CodeViewer();
154     }
155 }
156 ?>
[Raise a SilverStripe Framework issue/bug](https://github.com/silverstripe/silverstripe-framework/issues/new)
- [Raise a SilverStripe CMS issue/bug](https://github.com/silverstripe/silverstripe-cms/issues/new)
- Please use the Silverstripe Forums to ask development related questions. -
Webylon 3.2 API Docs API documentation generated by ApiGen 2.8.0