Exemplo n.º 1
0
 public function offsetGet($id)
 {
     if (!$this->offsetExists($id)) {
         if (array_key_exists($id, $this->keys)) {
             $file = $this->keys[$id];
             if (!file_exists($file)) {
                 $file = null;
             }
         } else {
             $arr = array('php', 'ini', 'yml', 'json', 'cache');
             foreach ($arr as $v) {
                 $file = $this->configDir . "/" . $id . "." . $v;
                 if (file_exists($file)) {
                     break;
                 } else {
                     $file = null;
                 }
             }
         }
         \Fobia\Debug\Log::debug(">> autoload config", array($id, $file));
         if (!$file) {
             trigger_error("Нет автозагрузочной секции конфигурации '{$id}'" . "/{$file}", E_USER_ERROR);
             return;
         }
         $this->values[$id] = Utils::loadConfig($file);
     }
     return $this->values[$id];
 }
Exemplo n.º 2
0
 public function offsetGet($id)
 {
     if (!$this->offsetExists($id)) {
         $this[$id] = function ($c) use($id) {
             $arr = array('php', 'ini', 'yml', 'json', 'cache');
             $configDir = $c['configDir']();
             foreach ($arr as $v) {
                 $file = $configDir . "/" . $id . "." . $v;
                 if (file_exists($file)) {
                     break;
                 } else {
                     $file = null;
                 }
             }
             \Fobia\Debug\Log::debug(">> autoload config", array($id, $file));
             if (!$file) {
                 trigger_error("Нет автозагрузочной секции конфигурации '{$id}'" . "/{$file}", E_USER_ERROR);
                 return;
             }
             return Utils::loadConfig($file);
         };
     }
     return parent::offsetGet($id);
 }
Exemplo n.º 3
0
 protected function dispatchRequest(\Slim\Http\Request $request, \Slim\Http\Response $response)
 {
     Log::debug('App run dispatch request');
     try {
         $this->applyHook('slim.before');
         ob_start();
         $this->applyHook('slim.before.router');
         $dispatched = false;
         $matchedRoutes = $this['router']->getMatchedRoutes($request->getMethod(), $request->getPathInfo(), true);
         foreach ($matchedRoutes as $route) {
             /* @var $route \Slim\Route */
             try {
                 $this->applyHook('slim.before.dispatch');
                 $dispatched = $route->dispatch();
                 $this->applyHook('slim.after.dispatch');
                 if ($dispatched) {
                     Log::debug('Route dispatched: ' . $route->getPattern());
                     break;
                 }
             } catch (\Slim\Exception\Pass $e) {
                 continue;
             }
         }
         if (!$dispatched) {
             $this->notFound();
         }
         $this->applyHook('slim.after.router');
     } catch (\Slim\Exception\Stop $e) {
     }
     $response->write(ob_get_clean());
     $this->applyHook('slim.after');
 }