protected function execute(InputInterface $input, OutputInterface $output)
 {
     $outputDir = $input->getOption('output-dir');
     $dump = Dump::load($outputDir);
     $dump->attachmentsDir = "{$outputDir}/attachments";
     assert_writable_dir($dump->attachmentsDir);
     $dump->write();
     $output->writeln('Get authenticated client.');
     $client = $this->getClient($input);
     $output->writeln('Start downloading files.');
     $progress = new ProgressBar($output, $dump->getTotalAttachmentSize());
     $progress->start();
     foreach ($dump->projects as $project) {
         foreach ($project->stories as $story) {
             foreach ($story->attachments as $attachment) {
                 $path = $dump->getAttachmentPath($attachment);
                 $this->downloadAttachment($client, $path, $project, $story, $attachment);
                 $progress->advance($attachment->sizeInBytes);
             }
         }
     }
     $progress->finish();
     $output->writeln('');
     $maxSize = round($dump->getBiggestAttachmentSize() / 1024);
     $output->writeln("Please ensure that Redmine maximum attachment size is greater than {$maxSize}.");
 }
示例#2
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $projects = $this->api->projects();
     $this->renderProjects($projects, $output);
     foreach ($projects as $project) {
         $output->writeln("Downloading stories for project #{$project->id}.");
         $project->stories = $this->api->stories($project->id);
         $output->writeln("Downloading attachment list for project #{$project->id}.");
         $attachmentsBar = new ProgressBar($output, count($project->stories));
         $attachmentsBar->start();
         foreach ($project->stories as $story) {
             $attachmentsBar->advance();
             $story->attachments = $this->api->attachments($project->id, $story->id);
         }
         $attachmentsBar->finish();
         $output->writeln('');
     }
     $dump = new Dump($this->outputDir);
     $dump->projects = $projects;
     $dump->write();
 }
示例#3
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->dump = Dump::load($input->getOption('output-dir'));
     $this->createUsers($this->dump->getUsers());
     $this->createProjects($this->dump->projects);
     /* HACK: It seems that the client caches the project list and won't
      * update it after creating a new one. We need to destroy and recreate
      * the client to be able to fetch project ids. */
     $this->initialize($input, $output);
     try {
         foreach ($this->dump->projects as $project) {
             $this->createProjectIssues($project);
         }
     } finally {
         $this->dump->write();
     }
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->dump = Dump::load($input->getOption('output-dir'));
     $map = [];
     foreach ($this->dump->projects as $project) {
         $phases = collection_column($project->phases, 'name');
         $statuses = array_keys($this->redmine->api('issue_status')->listing());
         $map[$project->id] = [];
         $output->writeln("For project #{$project->id} '{$project->name}':");
         foreach ($phases as $phase) {
             $helper = $this->getHelper('question');
             $question = new ChoiceQuestion("Map the AgileZen phase '{$phase}' to Redmine status:", $statuses);
             $question->setErrorMessage('Invalid status.');
             $map[$project->id][$phase] = $helper->ask($input, $output, $question);
         }
     }
     $this->dump->phaseMap = $map;
     $this->dump->write();
 }