public function actionCreateCategory() { $errors = array(); $apiAttributes = array('name' => '', 'description' => ''); $attributes = array_intersect_key($_GET, $apiAttributes); $category = new categories($attributes); if (!$category->validate()) { $errors = $category->getValidationErrors(); } if (!$errors) { if (!$category->save()) { $errors[] = 'The category could not be saved'; } else { $attributes = array('id', 'name', 'created', 'modified', 'description'); $data = array($this->returnValues($category, $attributes)); } } if ($errors) { $this->renderApi(false, null, $errors); } else { $this->renderApi(true, $data); } }