/** * @depends testMockRequest * @param $request */ public function testGetParams($request) { $params = Params::getMergeParams($request); $this->assertNotEmpty($params, 'params not empty'); $this->assertArrayHasKey('id', $params, 'params has id key'); $this->assertArrayHasKey('model', $params, 'params has model key'); $this->assertArrayHasKey('entity', $params, 'params has entity key'); $this->assertArrayHasKey('put', $params, 'params has put key'); $this->assertEquals($params['all'], null, 'param with key all equals getPut value'); }
/** * Delete record from DB. * @return array */ private function delete() { $params = Params::getMergeParams($this->request); if (empty($params['id'])) { return array('success' => false, 'msg' => 'param id is require'); } $id = intval($params['id']); $modelName = Analyzer::getModelName($this->request->get('_url')); /** * @var \Phalcon\Mvc\Model $model */ $model = $modelName::findFirst($id); if (!$model) { return array('success' => false, 'msg' => 'Record with id ' . $id . ' not found'); } $this->securityManager->check(array('model' => $model, 'action' => CrudOperations::DELETE, 'modelName' => $modelName, 'params' => $params)); $this->logManager->deleteModel($model); if ($model->delete()) { $this->logManager->deleteModel($model); return array('success' => true, 'msg' => 'Record with id ' . $id . ' has removed!'); } return array('success' => false, 'msg' => $this->jsonRecursiveGetMsg($model->getMessages())); }