Example #1
0
 public static function invoke($method, $req, ...$args)
 {
     $class = get_called_class();
     if (false === ($cache = Cache::get('controller', $class . '_' . $method))) {
         ob_start();
         $c = new $class();
         array_unshift($args, new Response());
         array_unshift($args, $req);
         $__melody_response = call_user_func_array(array($c, $method), $args);
         $buffer = ob_get_clean();
         return self::execute_view($__melody_response, $buffer, $class, $req);
     } else {
         return $cache;
     }
 }
Example #2
0
 static function Host_getConfigFromPath($path)
 {
     $cachename = 'action_' . implode('_', array_filter($path));
     if (false === ($cache = Cache::get('coreconfig/host', $cachename))) {
         $bufferedpath = '';
         $bufferedconfig = array();
         $isLast = true;
         $path = array_filter($path);
         $config = array();
         if (isset(self::$hosts['base_config']['path']['/'])) {
             $bufferedconfig = self::$hosts['base_config']['path']['/'];
             if ($bufferedconfig['recursive']) {
                 $config = $bufferedconfig;
             }
         }
         if (isset(self::$hosts['path']['/'])) {
             $bufferedconfig = self::$hosts['path']['/'];
         }
         if ($bufferedconfig['recursive']) {
             $config = $bufferedconfig;
         }
         while ($key = array_shift($path)) {
             $bufferedpath .= '/' . $key;
             if (isset(self::$hosts['path'][$bufferedpath])) {
                 $isLast = true;
                 $bufferedconfig = self::$hosts['path'][$bufferedpath];
                 if ($bufferedconfig['recursive']) {
                     $config = $bufferedconfig;
                 }
             } else {
                 $isLast = false;
             }
         }
         if ($isLast) {
             Cache::create('coreconfig/host', $cachename, $bufferedconfig, 'on_demand');
             return $bufferedconfig;
         } else {
             Cache::create('coreconfig/host', $cachename, $config, 'on_demand');
             return $config;
         }
     } else {
         return $cache;
     }
 }