private function parseForm(HTTPRequest $request, Category $category) { $name = htmlspecialchars($request->postData('name')); $description = htmlspecialchars($request->postData('description')); $isRoot = !$request->postExists('parent-category'); $category->setName($name); $category->setIsRoot($isRoot); $category->setDescription($description); if (!$isRoot) { $parentCategoryId = $request->postData('parent-category'); $category->setParentCategoryId($parentCategoryId); } }