Ejemplo n.º 1
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     // perform system reorganization
     $migration = new Migration($this->config, $this->view, $this->connection, $this->logger);
     $users = $input->getArgument('user_id');
     if (!empty($users)) {
         foreach ($users as $user) {
             if ($this->userManager->userExists($user)) {
                 $output->writeln("Migrating keys   <info>{$user}</info>");
                 $migration->reorganizeFolderStructureForUser($user);
             } else {
                 $output->writeln("<error>Unknown user {$user}</error>");
             }
         }
     } else {
         $output->writeln("Reorganize system folder structure");
         $migration->reorganizeSystemFolderStructure();
         $migration->updateDB();
         foreach ($this->userManager->getBackends() as $backend) {
             $name = get_class($backend);
             if ($backend instanceof IUserBackend) {
                 $name = $backend->getBackendName();
             }
             $output->writeln("Migrating keys for users on backend <info>{$name}</info>");
             $limit = 500;
             $offset = 0;
             do {
                 $users = $backend->getUsers('', $limit, $offset);
                 foreach ($users as $user) {
                     $output->writeln("   <info>{$user}</info>");
                     $migration->reorganizeFolderStructureForUser($user);
                 }
                 $offset += $limit;
             } while (count($users) >= $limit);
         }
     }
     $migration->finalCleanUp();
 }