Esempio n. 1
0
 public function createEmptyProject($title, $version)
 {
     $frame = new Frame();
     $frame->setId(new \MongoId());
     $frame->setEnabled(true);
     $frame->setLayers(array());
     $sequence = new Sequence();
     $sequence->setEnabled(true);
     $sequence->setFrames(array((string) $frame->getId()));
     $project = new Project();
     $project->setDateCreated(new \DateTime("now"));
     $project->setEnabled(true);
     $project->setPublished(false);
     $project->setAuthors($user->getDisplayName());
     $project->setUser($user);
     $project->setMobile(true);
     $project->setVersion($version);
     $project->addSequence($sequence);
     $project->addFrame($frame);
     if (isset($title)) {
         $project->setTitle($title);
     }
     if (isset($version)) {
         $project->setVersion($version);
     }
     $dm = $this->doctrine->getManager();
     $dm->persist($project);
     $dm->clear();
     return $project;
 }
Esempio n. 2
0
 /**
  * Create a new project
  * Route: POST api/projects
  *
  * @return Project id|response
  */
 public function postProjectAction()
 {
     $user = $this->get('security.context')->getToken()->getUser();
     $request = $this->getRequest();
     if ($request->request->has('title')) {
         $title = $request->request->get('title');
         $project->setTitle($title);
     }
     if ($request->request->has('version')) {
         $version = $request->request->get('version');
     } else {
         $version = 1.1;
     }
     $frame = new MongoFrame();
     $frame->setId(new \MongoId());
     $frame->setEnabled(true);
     $frame->setLayers(array());
     $sequence = new MongoSequence();
     $sequence->setEnabled(true);
     $sequence->setFrames(array((string) $frame->getId()));
     $project = new MongoProject();
     $project->setDateCreated(new \DateTime("now"));
     $project->setEnabled(true);
     $project->setPublished(false);
     $project->setAuthors($user->getDisplayName());
     $project->setUser($user);
     $project->setMobile(true);
     $project->setVersion($version);
     $project->addSequence($sequence);
     $project->addFrame($frame);
     $dm = $this->get('doctrine_mongodb')->getManager();
     $dm->persist($project);
     $dm->flush();
     return new Response($project->getPublicId());
 }