/**
  * @Route("/category/create")
  * @Method({"POST", "GET"})
  * @Template()
  *
  */
 public function createAction(Request $request)
 {
     $db = $this->getDoctrine()->getManager();
     try {
         $category = new Category();
         $category->setName($request->get('name'));
         if ($request->get('parent_id')) {
             $category->setParentId($request->get('parent_id'));
         }
         $db->persist($category);
         $db->flush();
         $message = 'Category %s was successfully created';
         $message = sprintf($message, $request->get('name'));
     } catch (\Exception $e) {
         $message = 'Error: ' . $e->getMessage();
     }
     return new JsonResponse(array('message' => $message));
 }
 /**
  * {@inheritDoc}
  */
 public function getName()
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'getName', array());
     return parent::getName();
 }