private function installResources($permissions) { foreach ($permissions 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); } } }
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(); }