Example #1
0
 /**
  * @Route("", name="post_todo_list")
  * @Method({"POST"})
  * @Rest\View()
  * @ApiDoc
  */
 public function postTodoListAction()
 {
     $data = $this->getRequest()->request;
     $todoList = new TodoList();
     $todoList->setTitle($data->get('title'));
     $em = $this->get('doctrine')->getManager();
     $em->persist($todoList);
     $em->flush();
     // creating the ACL
     $aclProvider = $this->get('security.acl.provider');
     $acl = $aclProvider->createAcl(ObjectIdentity::fromDomainObject($todoList));
     // retrieving the security identity of the currently logged-in user
     $securityContext = $this->get('security.context');
     $securityIdentity = UserSecurityIdentity::fromAccount($securityContext->getToken()->getUser());
     // grant owner access
     $acl->insertObjectAce($securityIdentity, MaskBuilder::MASK_OWNER);
     $aclProvider->updateAcl($acl);
     return RouteRedirectView::create('get_todo', array('id' => $todoList->getId()), HttpCodes::HTTP_CREATED);
 }
Example #2
0
 public function setTodoList(TodoList $todoList)
 {
     $this->todoList = $todoList;
     $this->todoList->addTodo($this);
 }