protected function execute(InputInterface $input, OutputInterface $output)
 {
     $item = new Item();
     $name = $input->getArgument('name');
     $location = $input->getArgument('location');
     $item->setName($name);
     $item->setLocation($location);
     $item->setDueDate(new \DateTime('tomorrow'));
     $item->setCreationTime(new \DateTime("now"));
     // write it into db
     $em = $this->getContainer()->get('doctrine.orm.entity_manager');
     $em->persist($item);
     $em->flush();
     $output->writeln("Successfuly added item to database.");
 }
 /**
  * @Route("/add", name="addNew")
  * @Template()
  */
 public function indexAction(Request $request)
 {
     if (!$this->get('user.services')->isUserLogged()) {
         return $this->redirectToRoute('login_route');
     }
     $post = new Item();
     $post->setCreationTime(new \DateTime("now"));
     $post->setDueDate(new \DateTime("tomorrow"));
     $form = $this->createFormBuilder($post)->add("Name", "text", ['attr' => ['class' => 'form-control']])->add("CreationTime", "date")->add("DueDate", "date")->add("Location", "text", ['attr' => ['class' => 'form-control']])->add("submit", "submit", ["label" => "ADD", 'attr' => ['class' => 'btn btn-primary']])->getForm();
     $form->handleRequest($request);
     if ($request->isMethod('POST') && $form->getClickedButton()) {
         $em = $this->getDoctrine()->getManager();
         $post->setUser($this->getActiveUser());
         $em->persist($post);
         $em->flush();
         return $this->redirectToRoute("home");
     }
     return $this->render("@ToDoPrvi/Default/addNew.html.twig", ["form" => $form->createView()]);
 }