Exemple #1
0
 public function getServices()
 {
     /*$response = new \Velox\Framework\Http\Response('blah');
       $cookie1 = new \Velox\Framework\Http\Cookie('1bbbbaa10', 'bb10');
       $cookie2 = new \Velox\Framework\Http\Cookie('2ccccaa11', 'bb11', '+10days');
       $response->setCookie($cookie1);
       $response->setCookie($cookie2);
       $response->send();*/
     /*$pb = new \Velox\Framework\Http\ParameterBag();
       $pb->setArray($_GET);
       _dump($pb->getString('tiv'));*/
     return array('Velox.Http.Request' => new Service(function () {
         return Request::createFromGlobals();
     }), 'Velox.Http.Response' => new Service(function () {
         return new Response();
     }), 'Velox.HttpRouter' => new Service(function () {
         $componentManager = Registry::get('Velox.ComponentManager');
         $router = new HttpRouter();
         $router->addRoutes($componentManager->getRoutes());
         return $router;
     }), 'MainDB' => new Service(function () {
         // load settings
         $driver = new Driver();
         $conf = (include 'config/db.config.php');
         $driver->connect($conf['host'], $conf['user'], $conf['password'], $conf['database']);
         return $driver;
     }));
 }
Exemple #2
0
 public function match(Request $request)
 {
     if (!is_null($this->method) && $this->method != $request->getMethod()) {
         return false;
     }
     $regexp = $this->getRegexp();
     $matches = array();
     $uri = $request->getRequestUri(false);
     $base = $request->server->getString('REDIRECT_BASE');
     if (strlen($base) < 1) {
         $uri = '/';
     } else {
         $uri = '/' . substr($uri, strlen($base));
     }
     $uri = preg_replace('#/+#', '/', $uri);
     if (preg_match($regexp, $uri, $matches)) {
         $this->setMatches($matches);
         return true;
     }
     return false;
 }