Exemplo n.º 1
0
 /**
  * Get varity response use fmt
  *
  * @param array $data
  * @param \Vine\Component\Http\RequestInterface $request
  *
  * @return \Vine\Component\Http\ResponseInterface
  */
 public static function getResponse(array $data, \Vine\Component\Http\RequestInterface $request)
 {
     /*{{{*/
     $fmtValue = $request->getParam(self::FMT_NAME);
     $response = null;
     $factory = new ResponseFactory();
     switch ($fmtValue) {
         case self::FMT_VALUE_DUMP:
             ob_start();
             var_dump($data);
             $content = ob_get_clean();
             $response = $factory->make($content);
             break;
         case self::FMT_VALUE_SERIALIZE:
             $content = serialize($data);
             $response = $factory->make($content);
             break;
         case self::FMT_VALUE_JSONP:
             $callback = $request->getParam(self::CALLBACK_NAME);
             $response = $factory->jsonp($callback, $data);
             break;
         case self::FMT_VALUE_JSON:
         default:
             $response = $factory->json($data);
     }
     return $response;
 }
Exemplo n.º 2
0
 /**
  * {@inheritdoc}
  */
 public function match(\Vine\Component\Http\RequestInterface $request, \Vine\Component\Routing\Route\RouteInterface $route)
 {
     /*{{{*/
     if (!preg_match($this->regex, $request->getUrlPath(), $matches)) {
         return false;
     }
     array_shift($matches);
     $route->setActionArgs($matches);
     return true;
 }
Exemplo n.º 3
0
 /**
  * {@inheritdoc}
  */
 public function match(\Vine\Component\Http\RequestInterface $request, &$actionArgs = array())
 {
     /*{{{*/
     if (!preg_match($this->regex, $request->getUrlPath(), $matches)) {
         return false;
     }
     array_shift($matches);
     $actionArgs = $matches;
     return true;
 }
Exemplo n.º 4
0
 /**
  * {@inheritdoc}
  */
 public function match(\Vine\Component\Http\RequestInterface $request, \Vine\Component\Routing\Route\RouteInterface $route)
 {
     /*{{{*/
     return strpos($request->getUrlPath(), $this->prefix) !== false ? true : false;
 }
Exemplo n.º 5
0
 /**
  * {@inheritdoc}
  */
 public function match(\Vine\Component\Http\RequestInterface $request, &$actionArgs = array())
 {
     /*{{{*/
     return strpos($request->getUrlPath(), $this->prefix) !== false ? true : false;
 }