Exemplo n.º 1
0
 /**
  * Clear all values stored in Configure.
  *
  * @return bool Success.
  */
 public static function clear()
 {
     static::$_values = array();
     return true;
 }
Exemplo n.º 2
0
 /**
  * Clear all values stored in Configure.
  *
  * @return bool success.
  */
 public static function clear()
 {
     static::$_values = [];
     return true;
 }
Exemplo n.º 3
0
 public static function match($pathComp, $route = null, $path = null)
 {
     if (empty($path)) {
         $path = trim(urldecode(static::$_uri), static::URI_DELIMITER);
         $path = empty($path) ? trim(urldecode($_SERVER['REQUEST_URI']), static::URI_DELIMITER) : trim(urldecode($path), static::URI_DELIMITER);
     }
     // $application = Bootstrap::$bag['config']->application;
     // $path        = strReplaceFirst($application->base_uri, '', $path);
     $path = '/' == $path[0] ? substr($path, 1) : $path;
     $pathComp = '/' == $pathComp[0] ? substr($pathComp, 1) : $pathComp;
     $pathComp = rtrim($pathComp, '/');
     $regex = '#^' . $pathComp . '$#';
     $res = preg_match($regex, $path, $values);
     if ($res === 0) {
         return false;
     }
     foreach ($values as $i => $value) {
         if (!is_int($i) || $i === 0) {
             unset($values[$i]);
         }
     }
     if (!empty($route) && count($values)) {
         foreach ($values as $key => $value) {
             $getter = 'settings' . $key;
             $settings = $route->{$getter};
             if (is_callable($settings)) {
                 $check = $settings($value);
                 if (false === $check) {
                     return false;
                 }
             }
         }
         static::$_values = $values;
         return true;
     }
     static::$_values = $values;
     return $values;
 }