예제 #1
0
 /**
  * Adds an album to the database.
  * Returns a JSON with the updated list of galleries viewable by user
  * @return Response
  */
 public function createGalleryAction()
 {
     //todo: change name to createAlbumAction
     $request = Request::createFromGlobals();
     $galleryName = $request->request->get('gallery_name', 'Ikke navngitt galleri.');
     $private = $request->request->get('private_gallery', 'public');
     $gallery = new Gallery();
     $gallery->setName($galleryName);
     $gallery->setPrivate($private != 'public');
     $gallery->setDateCreated(new \DateTime("now"));
     $gallery->setCreatedByUser($this->get('security.context')->getToken()->getUser());
     $em = $this->getDoctrine()->getManager();
     $em->persist($gallery);
     $em->flush();
     //return the updated list of galleries
     $response = $this->forward('AppBundle:Gallery:galleriesListGet');
     return $response;
 }
 /**
  * {@inheritDoc}
  */
 public function setName($name)
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'setName', array($name));
     return parent::setName($name);
 }