Exemplo n.º 1
0
 /**
  * @throws \Exception
  */
 public function __construct()
 {
     $default_config = self::loadConfig();
     $domain_config = self::loadConfig(Headers::get('Host'));
     if ($default_config || $domain_config) {
         $this->addConfig($default_config);
         $this->addConfig($domain_config);
     } else {
         throw new \Exception('No readable configurations.');
     }
 }
Exemplo n.º 2
0
 /**
  * Implements getValues.
  *
  * @return array
  */
 public function getValues()
 {
     $wildcard = FALSE;
     $full_path = Headers::get('CurrentPath');
     $path = explode('/', $full_path);
     if ($path_cache = Cache::get(self::PATH_CACHE . $full_path)) {
         $path_values = $this->path_query->getPathDataById($path_cache['id']);
         return $this->setupPathValues($path_values, $path_cache['query_parameters']);
     }
     $host = Headers::get('Host');
     if ($path[0] == "") {
         array_shift($path);
     }
     $query_parameters = array();
     while (count($path)) {
         $path_query = implode('/', $path);
         $path_values = $this->path_query->getPathDataFromPath($path_query, $host, $wildcard, true);
         if ($path_values) {
             $cache = array('id' => $path_values['_id']->{'$id'}, 'query_parameters' => $query_parameters);
             Cache::set(self::PATH_CACHE . $full_path, $cache);
             return $this->setupPathValues($path_values, $query_parameters);
         }
         if ($wildcard == TRUE) {
             $query_parameters[] = array_pop($path);
         }
         $wildcard = TRUE;
     }
     // We did not find a match send to the 404, if available.
     if (isset($this->config->FourOFour)) {
         if ($this->config->FourOFour === Headers::get('CurrentPath')) {
             Messages::set('Page Error', 'Error');
         } else {
             Redirect::set($this->config->FourOFour);
         }
     }
     return;
 }