/**
  * @Route("/advert_create", name="advert_create")
  * 
  */
 public function createAction(Request $request)
 {
     $em = $this->getDoctrine()->getManager();
     $form = $this->createForm(AdvertismentType::class);
     $form->handleRequest($request);
     if ($form->isValid()) {
         $registration = $form->getData();
         $date = new \DateTime();
         $nowdate = new \DateTime();
         $advert = new Advertisement();
         $advert->setTitle($registration['title']);
         $advert->setContents($registration['contents']);
         $advert->setCategory($registration['category']);
         $advert->setRegion($registration['region']);
         $advert->setImageFile($registration['imageFile']);
         $user = $this->getUser();
         $advert->setUser($user);
         $advert->setCreatedAt($nowdate);
         $advert->setExpirationAt($date->modify('+1 month'));
         $em->persist($advert);
         $em->flush();
     }
     //redirect after user create
     return $this->render('default/success.html.twig');
 }
 /**
  * {@inheritDoc}
  */
 public function setTitle($title)
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'setTitle', array($title));
     return parent::setTitle($title);
 }