Example #1
0
 public function execute(Request $request)
 {
     $url = $request->getUrl();
     $method = $request->getMethod();
     $parameters = $request->getParameters();
     $responseType = $request->getResponseType();
     // GET api/user/1.xml (get)
     if ($method === 'GET' && preg_match_all('/api\\/' . $this->name . '\\/([0-9]).xml/', $url, $matches)) {
         $id = $matches[1][0];
         return $this->execServer($request, array('_method' => $method, '_format' => $responseType, '_entity' => $this->name, '_action' => 'get', '_id' => $id), $parameters, $responseType);
     }
     // GET api/user.xml (list)
     if ($method === 'GET' && preg_match_all('/api\\/' . $this->name . '.xml/', $url, $matches)) {
         return $this->execServer($request, array('_method' => $method, '_format' => $responseType, '_entity' => $this->name, '_action' => 'list'), $parameters, $responseType);
     }
     // PUT api/user.xml (insert)
     if ($method === 'PUT' && preg_match_all('/api\\/' . $this->name . '.xml/', $url, $matches)) {
         return $this->execServer($request, array('_method' => $method, '_format' => $responseType, '_entity' => $this->name, '_action' => 'insert'), $parameters, $responseType);
     }
     // POST api/user/1.xml (update)
     if ($method === 'POST' && preg_match_all('/api\\/' . $this->name . '\\/([0-9]).xml/', $url, $matches)) {
         return $this->execServer($request, array('_method' => $method, '_format' => $responseType, '_entity' => $this->name, '_action' => 'update', '_id' => $parameters['id']), $parameters, $responseType);
     }
     // DELETE api/user/1.xml (delete)
     if ($method === 'DELETE' && preg_match_all('/api\\/' . $this->name . '\\/([0-9]).xml/', $url, $matches)) {
         return $this->execServer($request, array('_method' => $method, '_format' => $responseType, '_entity' => $this->name, '_action' => 'delete', '_id' => $matches[1][0]), $parameters, $responseType);
     }
 }