Я написал функцию, в которой передал все параметры для добавления пользователя.
public function userAddAction()
{
$this->requirePostParams(['username', 'usernameCanonical', 'email', 'emailCanonical', 'password', 'firstName', 'lastName', 'birthDay',
'addressOne', 'addressTwo', 'city', 'country', 'postCode', 'mobile', 'about']);
$this->get('user')->addNewUser($this->data['username'], $this->data['usernameCanonical'], $this->data['email'],
$this->data['password'], $this->data['emailCanonical'], $this->data['firstName'],
$this->data['lastName'], $this->data['birthDay'], $this->data['addressOne'],
$this->data['addressTwo'], $this->data['city'], $this->data['country'], $this->data['postCode'],
$this->data['mobile'], $this->data['about']);
return $this->success();
}
protected function requirePostParams($params)
{
$currentRequest = $this->get('request_stack')->getCurrentRequest();
$postData = $currentRequest->request->all();
$postContent = json_decode($currentRequest->getContent(), true);
if (!empty($postContent)) {
$postData = $postContent;
}
$this->data = $postData;
$missingParams = [];
foreach ($params as $param) {
if (!array_key_exists($param, $postData)) {
$missingParams[] = $param;
}
}
if (!empty($missingParams)) {
$this->terminateWithResponse($this->jsonError(sprintf("Missing params: %s", join(', ', $missingParams))));
}
}
Теперь я хочу упаковать все $ this-> data .... в один вызовуменьшите все поля, которые мне нужно набрать ..