private function getEditorUser() { $user = new User(); $ace = new AccessControlEntry(); $ace->setType('security'); $ace->setEntityId(AccessControlEntry::LEVEL_CONTENT_ADMIN); $ace->setGrantedBy(new User()); $user->addAce($ace); return $user; }
/** * @Given /^the administrator "([^"]*)" with the email "([^"]*)" and the password "([^"]*)"$/ */ public function createAdminUser($name, $email, $password) { $em = $this->getEntityManager(); $user = $this->createUser($name, $email, $password); $ace = new AccessControlEntry(); $ace->setUser($user); $ace->setEntityId(AccessControlEntry::LEVEL_FULL_ADMIN); $ace->setType('security'); $ace->setGrantedBy($user); $ace->setCreatedAt(new \DateTime()); $em->persist($ace); $em->flush(); }
/** * {@inheritDoc} */ public function load(ObjectManager $manager) { //Make the admin user an admin $e = new AccessControlEntry(); $e->setUser($this->getReference('adminuser')); $e->setGrantedBy($this->getReference('testuser1')); $e->setEntityId('-2'); $e->setCreatedAt(new \DateTime('2001-01-01')); $e->setType('security'); $manager->persist($e); //Make user2 owner of all shows $shows = $manager->getRepository('ActsCamdramBundle:Show')->findAll(); foreach ($shows as $show) { $e = new AccessControlEntry(); $e->setUser($this->getReference('testuser2')); $e->setGrantedBy($this->getReference('adminuser')); $e->setEntityId($show->getId()); $e->setCreatedAt(new \DateTime('2001-01-01')); $e->setType('show'); $manager->persist($e); } $manager->flush(); }
/** * Grant access to a resource. * * Immediately grant access to a resoure. Creates a new ACE in the * database, and dispatches a Camdram-specific event that is used * to trigger sending of emails. */ public function grantAccess(OwnableInterface $entity, User $user, User $granter) { $ace = new AccessControlEntry(); $ace->setUser($user); $ace->setEntityId($entity->getId())->setCreatedAt(new \DateTime())->setGrantedBy($granter)->setGrantedAt(new \DateTime())->setType($entity->getAceType()); $this->entityManager->persist($ace); $this->entityManager->flush(); /* Send a Camdram-specific event that should trigger an email * notification. */ $this->eventDispatcher->dispatch(CamdramSecurityEvents::ACE_CREATED, new AccessControlEntryEvent($ace)); }
public function testGetEntityIdsByUser_ValidClass() { $user = new User(); $user->setEmail('*****@*****.**'); $ace1 = new AccessControlEntry(); $ace1->setType('show'); $ace1->setEntityId(32); $ace2 = new AccessControlEntry(); $ace2->setType('show'); $ace2->setEntityId(44); $aces = array($ace1, $ace2); $this->repository->expects($this->once())->method('findByUserAndType')->with($user, 'show')->will($this->returnValue($aces)); $retAces = $this->aclProvider->getEntityIdsByUser($user, '\\Acts\\CamdramBundle\\Entity\\Show'); $this->assertEquals(32, $retAces[0]); $this->assertEquals(44, $retAces[1]); }