public function createApplication() { $required = array('name' => true, 'vk_app' => false, 'fb_app' => false, 'ok_app' => false, 'gcm_conf' => false, 'user_channel' => false, 'qa_channel' => false, 'qa_question_channel' => false, 'qa_answers_channel' => false, 'blacklist_channel' => false); $ownerId = $this->controller->identity->getId(); $params = $this->controller->getParams($required); $this->getConfigs($params); $application = new Application(); $application->setAttributes($params); $application->createAppSecret(); $application->owner_id = (int) $ownerId; if (!$application->save()) { if ($application->hasErrors()) { throw new ApiException($application->getErrors(), 500); } else { throw new ApiException('SaveFailed', 500); } } $this->controller->data = $application; }