Esempio n. 1
0
 public function resolve(Request $request, Response $response)
 {
     $commandPath = $this->basePath . '/' . $request->uri();
     if (!is_file($commandPath)) {
         throw new FrameworkException('Target command does not exist.');
     }
     require_once $commandPath;
     $fx = compose(unshiftsArg('str_replace', ' ', ''), 'ucwords', 'strtolower', unshiftsArg('str_replace', '-', ' '));
     $className = $fx($request->uri());
     if (!class_exists($className) || is_a($className, 'IExecutableCommand', true)) {
         throw new FrameworkException("File is loaded, expecting class {$className} from {$commandPath}.");
     }
     $command = new $className();
     $command->execute($request, $response);
 }
Esempio n. 2
0
 /**
  * @private
  *
  * Weak $needles will strip all weak tags in $haystack before matching,
  * otherwise it will invoke in_array() search as-is.
  */
 private function compareETags($needle, $haystack)
 {
     $haystack = (array) $haystack;
     // Weak entity-tag, strip all weak tags in $haystack
     if (strpos($needle, 'W/') === 0) {
         $needle = substr($needle, 2);
         $haystack = array_map(unshiftsArg('preg_replace', '/^W\\//', ''), $haystack);
     }
     return in_array($needle, $haystack);
 }