当前位置: 首页>>代码示例>>PHP>>正文


PHP Domain\ObjectIdentity类代码示例

本文整理汇总了PHP中Symfony\Component\Security\Acl\Domain\ObjectIdentity的典型用法代码示例。如果您正苦于以下问题:PHP ObjectIdentity类的具体用法?PHP ObjectIdentity怎么用?PHP ObjectIdentity使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ObjectIdentity类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: underlying

 /**
  * Constructs an underlying ObjectIdentity for given ObjectIdentity
  * Underlying is class level ObjectIdentity for given object level ObjectIdentity.
  *
  * @param ObjectIdentity $oid
  * @return ObjectIdentity
  * @throws InvalidAclException
  */
 public function underlying(ObjectIdentity $oid)
 {
     if ($oid->getIdentifier() === self::ROOT_IDENTITY_TYPE || $oid->getIdentifier() === ($extensionKey = $this->extensionSelector->select($oid)->getExtensionKey())) {
         throw new InvalidAclException(sprintf('Cannot get underlying ACL for %s', $oid));
     }
     return new ObjectIdentity($extensionKey, $oid->getType());
 }
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:15,代码来源:ObjectIdentityFactory.php

示例2: createTskAcl

 public function createTskAcl(Contact $contact)
 {
     $aclProvider = $this->getContainer()->get('security.acl.provider');
     $objectIdentity = ObjectIdentity::fromDomainObject($contact);
     $orgIdentity = 'ROLE_ORG_' . $contact->getOrganization()->getId();
     $orgSecurityIdentity = new RoleSecurityIdentity($orgIdentity);
     $builder = new MaskBuilder();
     $builder->add('VIEW');
     $builder->add('EDIT');
     $builder->add('CREATE');
     $builder->add('MASTER');
     try {
         try {
             $acl = $aclProvider->createAcl($objectIdentity);
             $acl->insertObjectAce($orgSecurityIdentity, $builder->get());
             foreach ($contact->getSchools() as $school) {
                 $schoolIdentity = 'ROLE_SCHOOL_' . $school->getId();
                 $schoolSecurityIdentity = new RoleSecurityIdentity($schoolIdentity);
                 $acl->insertObjectAce($schoolSecurityIdentity, $builder->get());
             }
             $aclProvider->updateAcl($acl);
         } catch (AclAlreadyExistsException $e) {
             // keep going ...
         }
     } catch (AclException $e) {
         throw $e;
     }
 }
开发者ID:sgh1986915,项目名称:symfony-tsk,代码行数:28,代码来源:LoadAclsCommand.php

示例3: postSave

 /**
  * This method is here to make your life better, so overwrite  it
  *
  * @param \Symfony\Component\Form\Form $form the valid form
  * @param \Taskeet\MainBundle\Entity\Event $Ticket your \Taskeet\MainBundle\Entity\Event object
  */
 public function postSave(\Symfony\Component\Form\Form $form, \Taskeet\MainBundle\Entity\Event $Event)
 {
     $proveedor = $this->container->get('security.acl.provider');
     $idObjeto = ObjectIdentity::fromDomainObject($Event);
     //poniendo al usuario logueado como owner
     $this->setPermissions($proveedor, $idObjeto, $this->getUser(), MaskBuilder::MASK_OWNER);
     if ($data = $form->get('repeat')->getData()) {
         $start = clone $form->get('startDate')->getData();
         $end = clone $form->get('dueDate')->getData();
         $ocurrences = $form->get('ocurrences')->getData();
         $interval = new DateInterval($form->get('repeat')->getData());
         $periodo = new \DatePeriod($start, $interval, $ocurrences, \DatePeriod::EXCLUDE_START_DATE);
         foreach ($periodo as $key => $fecha) {
             $event = clone $Event;
             $event->setStartDate($fecha);
             $event->setDueDate($end->add($interval));
             $event->setTitle(sprintf('%s-%s', $Event->getTitle(), $key));
             // $event->setSlug(sprintf('%s-%s', $Event->getSlug(), $key));
             $this->preSave($form, $event);
             $this->saveObject($event);
             $idObjeto = ObjectIdentity::fromDomainObject($event);
             $this->setPermissions($proveedor, $idObjeto, $this->getUser(), MaskBuilder::MASK_OWNER);
         }
     }
 }
开发者ID:jarmas8611,项目名称:proyect,代码行数:31,代码来源:NewController.php

示例4: createForm

 /**
  * Gets the form
  *
  * @param  \Sonata\AdminBundle\Util\AdminObjectAclData $data
  * @return \Symfony\Component\Form\Form
  */
 public function createForm(AdminObjectAclData $data)
 {
     // Retrieve object identity
     $objectIdentity = ObjectIdentity::fromDomainObject($data->getObject());
     $acl = $data->getSecurityHandler()->getObjectAcl($objectIdentity);
     if (!$acl) {
         $acl = $data->getSecurityHandler()->createAcl($objectIdentity);
     }
     $data->setAcl($acl);
     $masks = $data->getMasks();
     // Create a form to set ACL
     $formBuilder = $this->formFactory->createBuilder('form');
     foreach ($data->getAclUsers() as $aclUser) {
         $securityIdentity = UserSecurityIdentity::fromAccount($aclUser);
         foreach ($data->getUserPermissions() as $permission) {
             try {
                 $checked = $acl->isGranted(array($masks[$permission]), array($securityIdentity));
             } catch (NoAceFoundException $e) {
                 $checked = false;
             }
             $formBuilder->add($aclUser->getId() . $permission, 'checkbox', array('required' => false, 'data' => $checked));
         }
     }
     $form = $formBuilder->getForm();
     $data->setForm($form);
     return $form;
 }
开发者ID:saberyounis,项目名称:Sonata-Project,代码行数:33,代码来源:AdminObjectAclManipulator.php

示例5: createAction

 /**
  * Creates a new Url entity.
  *
  */
 public function createAction(Request $request)
 {
     $entity = new Url();
     $form = $this->createCreateForm($entity);
     $form->handleRequest($request);
     //        sets the author field to session username
     $entity->setAuthor($this->get('security.token_storage')->getToken()->getUser());
     if ($form->isValid()) {
         $em = $this->getDoctrine()->getManager();
         $em->persist($entity);
         $em->flush();
         //check logged in user for acl creation
         if ($this->get('security.authorization_checker')->isGranted('IS_AUTHENTICATED_FULLY')) {
             // creating the ACL
             $aclProvider = $this->get('security.acl.provider');
             $objectIdentity = ObjectIdentity::fromDomainObject($entity);
             $acl = $aclProvider->createAcl($objectIdentity);
             // retrieving the security identity of the currently logged-in user
             $tokenStorage = $this->get('security.token_storage');
             $user = $tokenStorage->getToken()->getUser();
             $securityIdentity = UserSecurityIdentity::fromAccount($user);
             // grant owner access
             $acl->insertObjectAce($securityIdentity, MaskBuilder::MASK_OWNER);
             $aclProvider->updateAcl($acl);
         }
         return $this->redirect($this->generateUrl('url_show', array('id' => $entity->getId())));
     }
     return $this->render('SurlUrlBundle:Url:new.html.twig', array('entity' => $entity, 'form' => $form->createView()));
 }
开发者ID:sidmahata,项目名称:surl,代码行数:33,代码来源:UrlController.php

示例6: setUp

 protected function setUp()
 {
     $this->initAutoload();
     $bbapp = $this->getBBApp();
     $this->initDb($bbapp);
     $this->getBBApp()->setIsStarted(true);
     $this->initAcl();
     $this->site = new Site();
     $this->site->setLabel('Test Site')->setServerName('test_server');
     $this->groupEditor = new Group();
     $this->groupEditor->setName('groupName');
     $this->groupEditor->setSite($this->site);
     $bbapp->getEntityManager()->persist($this->site);
     $bbapp->getEntityManager()->persist($this->groupEditor);
     $bbapp->getEntityManager()->flush();
     // setup ACE for site
     $aclProvider = $this->getSecurityContext()->getACLProvider();
     $objectIdentity = ObjectIdentity::fromDomainObject($this->site);
     $acl = $aclProvider->createAcl($objectIdentity);
     // retrieving the security identity of the currently logged-in user
     $securityIdentity = new UserSecurityIdentity($this->groupEditor->getName(), 'BackBee\\Security\\Group');
     // grant owner access
     $acl->insertObjectAce($securityIdentity, MaskBuilder::MASK_EDIT);
     $aclProvider->updateAcl($acl);
     // authenticate user , set up permissions
     $token = $this->createAuthUser('api_user', array('ROLE_API_USER'));
 }
开发者ID:gobjila,项目名称:BackBee,代码行数:27,代码来源:AclControllerTest.php

示例7: ofertaNuevaAction

 /**
  * Muestra el formulario para crear una nueva oferta y se encarga del
  * procesamiento de la información recibida y la creación de las nuevas
  * entidades de tipo Oferta
  */
 public function ofertaNuevaAction()
 {
     $peticion = $this->getRequest();
     $oferta = new Oferta();
     $formulario = $this->createForm(new OfertaType(), $oferta);
     if ($peticion->getMethod() == 'POST') {
         $formulario->bindRequest($peticion);
         if ($formulario->isValid()) {
             // Completar las propiedades de la oferta que una tienda no puede establecer
             $tienda = $this->get('security.context')->getToken()->getUser();
             $oferta->setCompras(0);
             $oferta->setRevisada(false);
             $oferta->setTienda($tienda);
             $oferta->setCiudad($tienda->getCiudad());
             // Copiar la foto subida y guardar la ruta
             $oferta->subirFoto($this->container->getParameter('cupon.directorio.imagenes'));
             $em = $this->getDoctrine()->getEntityManager();
             $em->persist($oferta);
             $em->flush();
             // Asignar el permiso necesario para que la tienda pueda modificar esta oferta
             $idObjeto = ObjectIdentity::fromDomainObject($oferta);
             $idUsuario = UserSecurityIdentity::fromAccount($tienda);
             $acl = $this->get('security.acl.provider')->createAcl($idObjeto);
             $acl->insertObjectAce($idUsuario, MaskBuilder::MASK_OPERATOR);
             $this->get('security.acl.provider')->updateAcl($acl);
             return $this->redirect($this->generateUrl('extranet_portada'));
         }
     }
     return $this->render('TiendaBundle:Extranet:formulario.html.twig', array('accion' => 'crear', 'formulario' => $formulario->createView()));
 }
开发者ID:neozoe,项目名称:Cupon,代码行数:35,代码来源:ExtranetController.php

示例8: createAction

 /**
  * @Route("/create", name="freedom_objective_dashboard_create", options={"expose"=true})
  * @Template()
  */
 public function createAction()
 {
     $objective = new Objective();
     $form = $this->createForm(new ObjectiveCreateType(), $objective);
     $request = $this->get('request');
     if ($request->getMethod() == 'POST') {
         $form->handleRequest($request);
         if ($form->isValid()) {
             $objective->setUser($this->getUser());
             $objective->setNbsteps(count($objective->getSteps()));
             foreach ($objective->getSteps() as $key => $value) {
                 $value->setObjective($objective);
                 $objective->addStep($value);
             }
             $em = $this->getDoctrine()->getManager();
             $em->persist($objective);
             $em->flush();
             //ACL
             $aclProvider = $this->get('security.acl.provider');
             $objectIdentity = ObjectIdentity::fromDomainObject($objective);
             $acl = $aclProvider->createAcl($objectIdentity);
             $securityContext = $this->get('security.context');
             $user = $securityContext->getToken()->getUser();
             $securityIdentity = UserSecurityIdentity::fromAccount($user);
             $acl->insertObjectAce($securityIdentity, MaskBuilder::MASK_OWNER);
             $aclProvider->updateAcl($acl);
             return $this->redirect($this->generateUrl('freedom_objective_dashboard_details', array('id' => $objective->getId())));
         }
     }
     return array('form' => $form->createView());
 }
开发者ID:MaximePlancke,项目名称:Freedom,代码行数:35,代码来源:DashboardController.php

示例9: load

 /**
  * {@inheritDoc}
  */
 public function load(ObjectManager $manager)
 {
     $stepOrg = new Organization();
     $stepOrg->setName('Step Inventory');
     $manager->persist($stepOrg);
     $demoOrg = new Organization();
     $demoOrg->setName('Acme Inc.');
     $manager->persist($demoOrg);
     $manager->flush();
     $this->addReference('stepOrg', $stepOrg);
     $this->addReference('demoOrg', $demoOrg);
     $aclProvider = $this->container->get('security.acl.provider');
     $devRoleSecurityIdentity = new RoleSecurityIdentity('ROLE_DEV');
     $adminRoleSecurityIdentity = new RoleSecurityIdentity('ROLE_ADMIN');
     $leadRoleSecurityIdentity = new RoleSecurityIdentity('ROLE_LEAD');
     $userRoleSecurityIdentity = new RoleSecurityIdentity('ROLE_USER');
     $objectIdentity = ObjectIdentity::fromDomainObject($stepOrg);
     $acl = $aclProvider->createAcl($objectIdentity);
     $acl->insertObjectAce($userRoleSecurityIdentity, MaskBuilder::MASK_VIEW);
     $acl->insertObjectAce($devRoleSecurityIdentity, MaskBuilder::MASK_OPERATOR);
     $aclProvider->updateAcl($acl);
     $objectIdentity = ObjectIdentity::fromDomainObject($demoOrg);
     $acl = $aclProvider->createAcl($objectIdentity);
     $acl->insertObjectAce($userRoleSecurityIdentity, MaskBuilder::MASK_VIEW);
     $acl->insertObjectAce($adminRoleSecurityIdentity, MaskBuilder::MASK_OPERATOR);
     $aclProvider->updateAcl($acl);
 }
开发者ID:belackriv,项目名称:step-inventory,代码行数:30,代码来源:LoadOrganizationData.php

示例10: newAction

 /**
  * New category page
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function newAction(Request $request)
 {
     $category = new Category();
     $user = $this->getUser();
     $category->setJeweler($user);
     //j'associe mon jeweler 1 à mon produit
     // je crée un formulaire de produit
     $form = $this->createForm(new CategoryType($user), $category, array('validation_groups' => 'new', 'attr' => array('method' => 'post', 'novalidate' => 'novalidate', 'action' => $this->generateUrl('store_backend_category_new'))));
     $form->handleRequest($request);
     if ($form->isValid()) {
         $em = $this->getDoctrine()->getManager();
         //je récupère le manager de Doctrine
         // j'upload mon fichier en faisant appel a la methode upload()
         $category->upload();
         $em->persist($category);
         //j'enregistre mon objet product dans doctrine
         $em->flush();
         //j'envoie ma requete d'insert à ma table product
         // création de l'ACL
         $aclProvider = $this->get('security.acl.provider');
         $objectIdentity = ObjectIdentity::fromDomainObject($category);
         $acl = $aclProvider->createAcl($objectIdentity);
         // retrouve l'identifiant de sécurité de l'utilisateur actuellement connecté
         $tokenStorage = $this->get('security.token_storage');
         $user = $tokenStorage->getToken()->getUser();
         $securityIdentity = UserSecurityIdentity::fromAccount($user);
         // donne accès au propriétaire
         $acl->insertObjectAce($securityIdentity, MaskBuilder::MASK_OWNER);
         $aclProvider->updateAcl($acl);
         $this->get('session')->getFlashBag()->add('success', 'Votre catégorie a bien été crée');
         return $this->redirectToRoute('store_backend_category_list');
         //redirection selon la route
     }
     return $this->render('StoreBackendBundle:Category:new.html.twig', array('form' => $form->createView()));
 }
开发者ID:unpetitlu,项目名称:store,代码行数:39,代码来源:CategoryController.php

示例11: load

 /**
  * {@inheritDoc}
  */
 public function load(ObjectManager $manager)
 {
     $tidLabel = new Label();
     $tidLabel->setName('TravelerId Label');
     $tidLabel->setDescription('ZPL TID Label');
     $tidLabel->setTemplate('
         ^XA
         ^FO50,50^BY3
         ^BCN,100,Y,N,N
         ^FD{{tid}}
         ^XZ
     ');
     $manager->persist($tidLabel);
     $manager->flush();
     //$this->addReference('dfwOffice', $dfwOffice);
     $aclProvider = $this->container->get('security.acl.provider');
     $devRoleSecurityIdentity = new RoleSecurityIdentity('ROLE_DEV');
     $adminRoleSecurityIdentity = new RoleSecurityIdentity('ROLE_ADMIN');
     $leadRoleSecurityIdentity = new RoleSecurityIdentity('ROLE_LEAD');
     $userRoleSecurityIdentity = new RoleSecurityIdentity('ROLE_USER');
     $objectIdentity = ObjectIdentity::fromDomainObject($tidLabel);
     $acl = $aclProvider->createAcl($objectIdentity);
     $acl->insertObjectAce($userRoleSecurityIdentity, MaskBuilder::MASK_VIEW);
     $acl->insertObjectAce($adminRoleSecurityIdentity, MaskBuilder::MASK_OPERATOR);
     $aclProvider->updateAcl($acl);
 }
开发者ID:belackriv,项目名称:step-inventory,代码行数:29,代码来源:LoadLabelData.php

示例12: updateAcl

 /**
  * Actualiza la acl del objeto en cuestión.
  *
  * @param $object
  * @param array $applyTo
  * @throws \Symfony\Component\Security\Acl\Exception\InvalidDomainObjectException
  */
 public function updateAcl($object, $applyTo = array())
 {
     $objectIdentity = ObjectIdentity::fromDomainObject($object);
     $aclProviderCallable = $this->aclProviderCallable;
     $aclProviderCallable($objectIdentity, 'delete');
     $acl = $aclProviderCallable($objectIdentity, 'create');
     $this->applyAcl($acl, $applyTo);
 }
开发者ID:admarin1985,项目名称:tickets,代码行数:15,代码来源:AclManager.php

示例13: getObjectIdentity

 /**
  * {@inheritDoc}
  */
 public function getObjectIdentity($domainObject)
 {
     try {
         return ObjectIdentity::fromDomainObject($domainObject);
     } catch (InvalidDomainObjectException $failed) {
         return null;
     }
 }
开发者ID:nickaggarwal,项目名称:sample-symfony2,代码行数:11,代码来源:ObjectIdentityRetrievalStrategy.php

示例14: testFromDomainObjectWithoutInterfaceAllowsZeroAsIdentifier

 public function testFromDomainObjectWithoutInterfaceAllowsZeroAsIdentifier()
 {
     $domainObject = new TestDomainObject();
     $domainObject->id = '0';
     $id = ObjectIdentity::fromDomainObject($domainObject);
     $this->assertSame('0', $id->getIdentifier());
     $this->assertEquals('Symfony\\Component\\Security\\Acl\\Tests\\Domain\\TestDomainObject', $id->getType());
 }
开发者ID:Dren-x,项目名称:mobit,代码行数:8,代码来源:ObjectIdentityTest.php

示例15: test_vote_objectScope

 public function test_vote_objectScope()
 {
     $aclManager = $this->getBBApp()->getContainer()->get('security.acl_manager');
     $aclManager->insertOrUpdateClassAce(ObjectIdentity::fromDomainObject($this->user), new UserSecurityIdentity($this->group->getObjectIdentifier(), get_class($this->group)), MaskBuilder::MASK_EDIT);
     $this->assertEquals(BBAclVoter::ACCESS_GRANTED, $this->aclVoter->vote($this->token, $this->user, ['EDIT']));
     $this->assertEquals(BBAclVoter::ACCESS_DENIED, $this->aclVoter->vote($this->token, new ObjectIdentity('all', get_class($this->user)), ['EDIT']));
     $this->assertEquals(BBAclVoter::ACCESS_DENIED, $this->aclVoter->vote($this->token, new ObjectIdentity(23545866754, get_class($this->user)), ['EDIT']));
 }
开发者ID:cmarianhodis,项目名称:BackBee,代码行数:8,代码来源:BBAclVoterTest.php


注:本文中的Symfony\Component\Security\Acl\Domain\ObjectIdentity类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。