public function testConstructor() { foreach (self::$crud as $url => $params) { $paramsObj = new Params($url, $params); $prepareParams = $paramsObj->getPrepareParams(); $this->assertEquals(self::$expected[$url], $prepareParams, 'getPrepareParams return expected value'); } }
/** * @param ResultsetInterface $data * @param array $params * @param $url * @return array */ private function getFinallyFullData(ResultsetInterface $data, array $params, $url) { $isOnlyFirst = !Analyzer::hasMany($url); $isFetchRelations = \PPA\Rest\Request\Params::isNeedFetchRelations($params); $isJoinedRelations = \PPA\Rest\Request\Params::isNeedJoinedRelations($params); $needleRelations = empty($params['fetchRelations']) ? array() : (array) $params['fetchRelations']; if ($isOnlyFirst) { /** * @var \Phalcon\Mvc\Model $data */ $data = $data->getFirst(); if (!$data) { return array(); } if ($isFetchRelations) { return $data->fetchRelations(true, $needleRelations)->toArrayRelations(); } if ($isJoinedRelations) { return $data->joinedRelations()->toArrayRelations(); } return $data->toArray(); } return $data->filter(function ($model) use($isFetchRelations, $isJoinedRelations, $needleRelations) { if ($isFetchRelations) { return $model->fetchRelations(true, $needleRelations); } if ($isJoinedRelations) { return $model->joinedRelations(); } return $model; }); }