Example #1
0
 public function formAddUserRoleSubmitted(\Nette\Forms\Form $form)
 {
     $values = $form->values;
     var_dump($values);
     $template = $values->template;
     $roleName = $values->name;
     $role = new \Entity\UserRole();
     $role->setName($roleName);
     if ($template != '') {
         $templateRole = $this->em->getRepository('UserRole')->find($template);
         var_dump($templateRole);
         $this->em->detach($templateRole);
         var_dump($templateRole);
         exit;
     }
 }
Example #2
0
 public function installUserRoles()
 {
     $user = new \Entity\UserRole();
     $admin = new \Entity\UserRole();
     $admin->setName('Admin');
     $adminResource = new \Entity\Resource('all');
     $adminPermission = new \Entity\Permission();
     $adminPermission->setResource($adminResource)->setPrivilege('all')->setPrivilegeText('All');
     $admin->addPermission($adminPermission);
     $this->entityManager->persist($admin);
     $user->setName('User');
     $this->entityManager->persist($user);
     /*
             $tatamiModule = new Modules\TatamiModule;
             $tatamiPermissions = $tatamiModule->getPermissions();
             
             foreach($tatamiPermissions as $resourceName => $privileges)
             {
                 $resource = new \Entity\Resource($resourceName);
                 
                 foreach($privileges as $privilege => $privilegeText)
                 {
                     $permission = new \Entity\Permission;
                     $permission->setResource($resource)->setPrivilege($privilege)
                             ->setPrivilegeText($privilegeText);
     		$this->entityManager->persist($permission);
                 }        
             }
     */
     $this->entityManager->flush();
 }