Exemplo n.º 1
0
 /**
  * @Route("", name="add_widget")
  * @Method({"POST"})
  * @ApiDoc
  */
 public function postWidgetAction()
 {
     $data = $this->getRequest()->request;
     $em = $this->get('doctrine')->getManager();
     $widget = new Widget($data->get('identifier'), $data->get('title'), $data->get('description'), $data->get('title'));
     $widget->setWorkspace($em->getRepository('CorujaPlesyndBundle:Workspace')->findOneBy(array('id' => $data->get('workspace_id'))));
     $widget->setIsOfflineCompatible($data->get('is_offline_compatible'));
     $em->flush();
     // creating the ACL
     $aclProvider = $this->get('security.acl.provider');
     $acl = $aclProvider->createAcl(ObjectIdentity::fromDomainObject($widget));
     // 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_widget', array('id' => $widget->getId()), HttpCodes::HTTP_CREATED);
 }
Exemplo n.º 2
0
 public function addWidget(Widget $widget)
 {
     $widget->setPosition($this->widgets->count() + 1);
     $this->widgets->add($widget);
 }