Exemple #1
0
 /**
  * The Autoloader initialisation
  *
  * @return void
  */
 public static function _init()
 {
     // is the profiler enabled?
     if (!(static::$_enabled = ClanCats::$config->get('profiler.enabled'))) {
         return;
     }
     // enable profiling only in development mode
     if (ClanCats::in_development()) {
         // add a hook to the resposne so that we can
         // append a table with the profiler data to the body
         CCEvent::mind('response.output', function ($output) {
             if (strpos($output, '</body>') === false) {
                 return $output;
             }
             $table = \UI\Table::create(array('style' => array('width' => '100%'), 'cellpadding' => '5', 'class' => 'table debug-table debug-table-profiler'));
             $table->header(array('#', 'message', 'memory', 'time'));
             foreach (\CCProfiler::data() as $key => $item) {
                 $table->row(array($key + 1, $item[0], $item[1], $item[2]));
             }
             // add the table before the body end
             return str_replace('</body>', $table . "\n</body>", $output);
         });
         // also add an error inspector hook so that we can access the
         // profiler data in the error handler
         CCError_Inspector::info_callback('Profiler', function () {
             $table = array();
             foreach (\CCProfiler::data() as $key => $check) {
                 $table['#' . ($key + 1) . ': ' . $check[2]] = $check[0];
             }
             return $table;
         });
     }
 }
Exemple #2
0
 /**
  * CCProfiler::check tests
  */
 public function test_enable_disable()
 {
     $checks = count(CCProfiler::data());
     CCProfiler::check('check 1');
     $this->assertEquals(count(CCProfiler::data()), $checks + 1);
     CCProfiler::disable();
     CCProfiler::check('check 2');
     $this->assertEquals(count(CCProfiler::data()), $checks + 1);
     CCProfiler::enable();
     CCProfiler::check('check 3');
     $this->assertEquals(count(CCProfiler::data()), $checks + 2);
 }
Exemple #3
0
 /**
  * Environment wake
  * This is an environment wake they get called if your running
  * the application in a special environment like:
  *     wake_production
  *     wake_phpunit
  *     wake_test
  *
  * @return void | CCResponse
  */
 public static function wake_development()
 {
     CCProfiler::check('App::development - Application finished wake events.');
 }
Exemple #4
0
$paths = (require CCROOT . 'boot/paths' . EXT);
/*
 *---------------------------------------------------------------
 * the direcotries
 *---------------------------------------------------------------
 * 
 * Here are the module directories defined. 
 * @ToDo: move them to the classes that use that direcotries. 
 *        that way the you could subclass a class and define 
 *        a custom direcotry.
 */
$directories = array('controller' => 'controllers/', 'language' => 'language/', 'class' => 'classes/', 'console' => 'console/', 'config' => 'config/', 'view' => 'views/', 'test' => 'tests/');
/*
 *---------------------------------------------------------------
 * wake CCF
 *---------------------------------------------------------------
 * 
 * Lets require the ClanCatsFramework resources
 */
require $paths['core'] . 'wake' . EXT;
/*
 *---------------------------------------------------------------
 * wake the application
 *---------------------------------------------------------------
 * 
 * Lets wake the main application.
 */
ClanCats::wake_app('App');
// at this point the app has completet its own boot
CCProfiler::check("CCF - App completed.");
Exemple #5
0
 /**
  * send response
  * means printing the response and setting the headers if set
  *
  * @param bool		$headers	
  * @return  void
  */
 public function send($headers = false)
 {
     if ($headers && headers_sent() && !CLI) {
         throw new CCException("CCResponse::send - cannot send header, header has already been send.");
     }
     if ($headers) {
         // status header
         header(CCIn::server('SERVER_PROTOCOL') . ' ' . $this->_status . ' ' . CCResponse::$messages[$this->_status]);
         // check if content type is already set
         if (!isset($this->_header['Content-Type'])) {
             $this->header('Content-Type', 'text/html; charset=' . ClanCats::$config->get('charset', 'utf-8'));
         }
         $this->header('X-Powered-By', 'ClanCatsFramework version: ' . ClanCats::VERSION);
         // set headers
         foreach ($this->_header as $key => $content) {
             header($key . ': ' . $content);
         }
     }
     // profiler
     CCProfiler::check('CCResponse - sending response');
     // print the body
     echo CCEvent::pass('response.output', $this->body());
 }
Exemple #6
0
 *---------------------------------------------------------------
 * Require the application map
 *---------------------------------------------------------------
 * 
 * The application map can contain additional path information
 */
if (file_exists(APPPATH . 'map' . EXT)) {
    require APPPATH . 'map' . EXT;
}
/*
 *---------------------------------------------------------------
 * composer / vendor
 *---------------------------------------------------------------
 * 
 * After ccf is done with its own initialisation we implement the
 * composers vendor autoloader.
 */
require_once VENDORPATH . "autoload" . EXT;
// at this point vendor autoloader is registered
CCProfiler::check("CCF - Vendro autoloader registered.");
/*
 *---------------------------------------------------------------
 * installed ships
 *---------------------------------------------------------------
 * 
 * Load and wake all installed ships.
 */
CCOrbit::enter_installed_ships();
// all done
CCProfiler::check("CCF - All runtime ships entered the Orbit.");
Exemple #7
0
 /**
  * Add a ship
  * this loads the ship loader file
  *
  * @param string		$path
  * @return bool
  */
 public static function enter($path)
 {
     if (!is_array($path)) {
         $path = array($path);
     }
     foreach ($path as $ship) {
         // load ship at path
         $ship = CCOrbit_Ship::create($ship);
         if (array_key_exists($ship->name, static::$ships)) {
             throw new CCException("CCOrbit::enter - {$ship->name} ship already entered.");
         }
         if ($ship->wake !== false) {
             $ship->event($ship->wake);
         }
         CCProfiler::check("CCOrbit - ship {$ship->name} launched.");
         // add to our loaded ships
         static::$ships[$ship->name] = $ship;
     }
 }