Ejemplo n.º 1
0
 /** This method is the main controller */
 public static function serveWeb()
 {
     if (Config::get('PROFILING_ENABLED')) {
         Profiling::start('index');
     }
     $url = $_SERVER['REQUEST_URI'];
     $hash = md5($url);
     if (!@(include 'cache/' . $hash)) {
         Router::setUrl($url);
         switch (Router::$node->getProperty('type')) {
             case 'page':
             case 'root':
                 ControllerPage::compile();
                 break;
             case 'php':
                 ControllerPhp::compile();
                 break;
         }
     }
     if (Config::get('PROFILING_ENABLED')) {
         Profiling::end();
     }
 }
Ejemplo n.º 2
0
 private static function _init()
 {
     if (null === self::$_instance) {
         self::$_instance = new Profiling();
     }
 }
Ejemplo n.º 3
0
 public function staticPrimitiveMemberNotInValues()
 {
     Profiling::$fixture = array($this, $this->name);
     $this->assertEquals(array(Profiling::$INSTANCE, Profiling::$EXTENSION), Profiling::values());
     Profiling::$fixture = NULL;
 }
Ejemplo n.º 4
0
 public static function callStack()
 {
     $GC = CARRY('get_class');
     $callstack = Tree::getActiveCallstack();
     $count = count($callstack);
     Tree::$currentIndex = count(Tree::getActiveNodes()) - 1;
     if (!$count) {
         return false;
     }
     for ($i = 0; $i < $count; $i++) {
         foreach (array_keys($callstack[$i]) as $key) {
             if (strpos($key, '_') === 0) {
                 $callstack[$i][substr($key, 1)] = $callstack[$i][$key];
                 unset($callstack[$i][$key]);
             } elseif ($i < $count - 1) {
                 unset($callstack[$i][$key]);
             }
         }
     }
     $final = array();
     for ($i = $count - 1; $i >= 0; $i--) {
         $final += $callstack[$i];
     }
     ksort($final);
     foreach ($final as $key => $value) {
         if (is_string($value)) {
             $name = "{$value}";
         } elseif (is_array($value) and is_string($value[0])) {
             $name = "{$value[0]}";
         } elseif (is_array($value) and is_array($value[0]) and is_string($value[0][0])) {
             $name = "{$value[0][0]}, {$value[0][1]}";
         } elseif (is_array($value) and is_array($value[0]) and is_object($value[0][0])) {
             $name = "{$GC($value[0][0])}, {$value[0][1]}";
         } elseif (is_closure($value)) {
             $name = "CLOSURE ({$key})";
         } else {
             continue;
         }
         Profiling::start($name);
         if (is_closure($value)) {
             $value();
         } else {
             if (is_string($value)) {
                 $value = array($value);
             }
             $function = array_shift($value);
             call_user_func_array($function, $value);
         }
         Profiling::stop();
     }
     return true;
 }
Ejemplo n.º 5
0
 static function __static()
 {
     self::$INSTANCE = new self(0, 'INSTANCE');
     self::$EXTENSION = new self(1, 'EXTENSION');
 }