Пример #1
0
 public function checkIntegrity()
 {
     $this->log('Checking workspace roles integrity.');
     $workspaces = $this->workspaceRepo->findAll();
     $i = 0;
     $this->om->startFlushSuite();
     foreach ($workspaces as $workspace) {
         $this->log('Checking collaborator role for workspace ' . $workspace->getCode() . '...');
         $collaborator = $this->getCollaboratorRole($workspace);
         if (!$collaborator) {
             $this->log('Adding collaborator role for workspace ' . $workspace->getCode() . '...', LogLevel::DEBUG);
             $this->createWorkspaceRole('ROLE_WS_COLLABORATOR_' . $workspace->getGuid(), 'collaborator', $workspace, true);
             $i++;
             if ($i % 300 === 0) {
                 $this->om->forceFlush();
             }
         }
     }
     $this->om->endFlushSuite();
     $this->log('Checking user role integrity.');
     $users = $this->container->get('claroline.manager.user_manager')->getAllEnabledUsers();
     $this->om->startFlushSuite();
     foreach ($users as $user) {
         $this->log('Checking personal role for ' . $user->getUsername());
         $roleName = 'ROLE_USER_' . strtoupper($user->getUsername());
         $role = $this->roleRepo->findOneByName($roleName);
         if (!$role) {
             $this->log('Adding user role for ' . $user->getUsername(), LogLevel::DEBUG);
             $this->createUserRole($user);
             $i++;
             if ($i % 300 === 0) {
                 $this->om->forceFlush();
             }
         }
     }
     $this->om->endFlushSuite();
 }