/**
  * @Security("has_role('ROLE_APP_ADMIN')")
  */
 public function createAction($name)
 {
     $category = new Category();
     $category->setName($name);
     $validator = $this->get("validator");
     $errors = $validator->validate($category);
     if (count($errors) > 0) {
         $errorsString = (string) $errors;
         return $this->render("DWSBundle::index.html.twig", array("text" => $errorsString));
     }
     $this->addAction($category);
     $categories = $this->searchAllAction();
     return $this->render("DWSBundle:Category:list.html.twig", array("category" => $category, "flashcategoryadd" => true, "categories" => $categories));
 }
 public function load(ObjectManager $manager)
 {
     $root = $this->container->getParameter('kernel.root_dir');
     $dir = str_replace('/app', '/src/DWSBundle/Resources/data/', $root);
     $fd = fopen($dir . 'categories.csv', "r");
     if ($fd) {
         while (($data = fgetcsv($fd)) !== false) {
             $category = new Category();
             $category->setName($data[0]);
             $manager->persist($category);
             $manager->flush();
         }
         fclose($fd);
     }
 }
 private function initCategory()
 {
     $category = $this->searchByNameAction(CategoryController::$name_default);
     if (!$category) {
         $category = new Category();
         $category->setName(CategoryController::$name_default);
         $validator = $this->get("validator");
         $errors = $validator->validate($category);
         if (count($errors) > 0) {
             $errorsString = (string) $errors;
             return $this->render("DWSBundle::index.html.twig", array("text" => $errorsString));
         }
         $category->addAction($category);
     }
     return $category;
 }