/** * @return array */ public function crudAction() { try { $url = $this->request->get('_url'); if (!$url) { throw new \PPA\Rest\Exception('_url is mast specific'); } if (Analyzer::isSaving($url)) { return $this->save(); } if (Analyzer::isDeleting($url)) { return $this->delete(); } $params = Params::getMergeParams($this->request); $query = Operators::buildQuery($url, $params); $data = $query->execute(); $this->securityManager->check(array('model' => $data, 'action' => CrudOperations::READ, 'modelName' => Analyzer::getModelName($url), 'params' => $params)); if (!$data) { return array(); } return $this->getFinallyFullData($data, $params, $url); } catch (\PPA\Rest\Acl\Exception $e) { $this->response->setStatusCode(401); return array('msg' => $e->getMessage(), 'url' => $url); } catch (\PPA\Rest\Exception $e) { $this->response->setStatusCode(500); return array('msg' => $e->getMessage(), 'trace' => $e->getTrace()); } }
public function testIsSaving() { $operatorExpected = 'save'; foreach (self::$variation as $suffix) { foreach (self::$crud as $key => $operation) { foreach ($operation as $url) { $this->assertEquals(Analyzer::isSaving($url . $suffix), $key === $operatorExpected ? true : false, 'isSaving ' . $key === $operatorExpected ? '' : 'not' . ' equal fetch url with ' . $url . $suffix); } } } }