Beispiel #1
0
 public function execute(ParametersInterface $params)
 {
     if (!$this->endpoint->validateParameters($params)) {
         throw new \Exception('Not valid parameters!');
     }
     try {
         if (is_null($this->callback)) {
             if ($this->endpoint instanceof ExecutableEndpointInterface) {
                 $response = $this->endpoint->execute($params);
             } else {
                 throw new \Exception(sprintf('Endpoint %s is not executable.', $this->endpoint->getUri()));
             }
         } else {
             $callback = $this->callback;
             $response = $callback($params);
         }
     } catch (\Exception $e) {
         $response = $e;
     }
     if (is_null($this->adapter)) {
         return $response;
     } else {
         return $this->adapter->response($response);
     }
 }
 public function dispatch(ParametersInterface $params)
 {
     if (!$this->endpoint->validateParameters($params)) {
         throw new \Exception('Not valid parameters!');
     }
     $response = $this->adapter->request($this->endpoint, $params);
     if ($response instanceof \Exception) {
         throw $response;
     }
     return $response;
 }