public function handleSave($form)
 {
     $values = $form->getValues();
     $entity = $form->data;
     $entity->getPermissions()->clear();
     foreach ($values as $resource => $items) {
         foreach ($items['privileges'] as $privilege => $item) {
             if ($item) {
                 $entity->permissions[] = new \CmsModule\Security\Entities\PermissionEntity($entity, $this->unformatName($resource), $privilege);
             }
         }
     }
     $this->addPermissions($entity, $values);
     $this->repository->save($form->data);
 }
Beispiel #2
0
 /**
  * @return ExtendedUserEntity
  */
 protected function createNewUser()
 {
     $repository = $this->entityManager->getRepository($this->userType);
     /** @var $entity ExtendedUserEntity */
     $entity = $repository->createNew();
     if ($this->mode === 'checkup') {
         $entity->getUser()->setPublished(false);
     } elseif ($this->mode === 'mail') {
         $entity->getUser()->disableByKey();
     } elseif ($this->mode === 'mail&checkup') {
         $entity->getUser()->disableByKey();
         $entity->getUser()->setPublished(false);
     }
     foreach ((array) $this->roles as $role) {
         $entity->getUser()->roleEntities[] = $this->roleRepository->findOneBy(array('name' => $role));
     }
     return $entity;
 }
 protected function getRoles()
 {
     return $this->roleRepository->fetchPairs('name', 'name');
 }