Наследование: extends Sulu\Bundle\CoreBundle\Entity\ApiEntity
Пример #1
0
 public function setUp()
 {
     $this->user = new User();
     $this->userRole = new UserRole();
     $this->role = new Role();
     $this->permission = new Permission();
     $this->permission->setPermissions(122);
     $this->permission->setContext('sulu.security.roles');
     $this->role->addPermission($this->permission);
     $this->userRole->setRole($this->role);
     $this->user->addUserRole($this->userRole);
     $this->userGroup = new UserGroup();
     $this->group = new Group();
     $this->role = new Role();
     $this->permission = new Permission();
     $this->permission->setPermissions(122);
     $this->permission->setContext('sulu.security.groups');
     $this->role->addPermission($this->permission);
     $this->group->addRole($this->role);
     $this->userGroup->setGroup($this->group);
     $this->nestedGroup = new Group();
     $this->role = new Role();
     $this->permission = new Permission();
     $this->permission->setPermissions(122);
     $this->permission->setContext('sulu.security.groups.nested');
     $this->role->addPermission($this->permission);
     $this->nestedGroup->addRole($this->role);
     $this->group->addChildren($this->nestedGroup);
     $this->user->addUserGroup($this->userGroup);
     $this->token = $this->prophesize(TokenInterface::class);
     $this->token->getUser()->willReturn($this->user);
     $this->aclProvider = $this->prophesize(AclProviderInterface::class);
     $this->aclProvider->findAcl(Argument::any())->willReturn(true);
     $this->voter = new SecurityContextVoter($this->permissions, $this->aclProvider->reveal());
 }
Пример #2
0
 /**
  * Updates an existing UserGroup with the given data.
  *
  * @param \Sulu\Bundle\SecurityBundle\Entity\UserGroup $userGroup
  * @param $userGroupData
  *
  * @throws \Sulu\Component\Rest\Exception\EntityNotFoundException
  *
  * @return bool
  */
 private function updateUserGroup(UserGroup $userGroup, $userGroupData)
 {
     $group = $this->groupRepository->findGroupById($userGroupData['group']['id']);
     if (!$group) {
         throw new EntityNotFoundException($this->groupRepository->getClassName(), $userGroup['group']['id']);
     }
     $userGroup->setGroup($group);
     if (array_key_exists('locales', $userGroupData)) {
         $userGroup->setLocale(json_encode($userGroupData['locales']));
     } else {
         $userGroup->setLocale($userGroupData['locale']);
     }
     return true;
 }