コード例 #1
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $output->setDecorated(true);
     $this->appState->setAreaCode('catalog');
     $connection = $this->attributeResource->getConnection();
     $attributeTables = $this->getAttributeTables();
     $progress = new \Symfony\Component\Console\Helper\ProgressBar($output, count($attributeTables));
     $progress->setFormat('<comment>%message%</comment> %current%/%max% [%bar%] %percent:3s%% %elapsed%');
     $this->attributeResource->beginTransaction();
     try {
         // Find and remove unused attributes
         foreach ($attributeTables as $attributeTable) {
             $progress->setMessage($attributeTable . ' ');
             $affectedIds = $this->getAffectedAttributeIds($connection, $attributeTable);
             if (count($affectedIds) > 0) {
                 $connection->delete($attributeTable, ['value_id in (?)' => $affectedIds]);
             }
             $progress->advance();
         }
         $this->attributeResource->commit();
         $output->writeln("");
         $output->writeln("<info>Unused product attributes successfully cleaned up:</info>");
         $output->writeln("<comment>  " . implode("\n  ", $attributeTables) . "</comment>");
     } catch (\Exception $exception) {
         $this->attributeResource->rollBack();
         $output->writeln("");
         $output->writeln("<error>{$exception->getMessage()}</error>");
     }
 }
コード例 #2
0
ファイル: CommandVcs.php プロジェクト: larakit/cmd-vcs
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $path = base_path('vendor');
     $vendor_paths = \File::directories($path);
     $path = rtrim(rtrim($path, '\\'), '/');
     $this->info('Сканируем установленные пакеты на наличие папок .git и .svn');
     $check_directories = [];
     foreach ($vendor_paths as $vendor_path) {
         $package_paths = File::directories($vendor_path);
         foreach ($package_paths as $package_path) {
             $check_directories[] = (string) $package_path;
         }
     }
     $progress = new \Symfony\Component\Console\Helper\ProgressBar($this->output, sizeof($check_directories));
     $progress->setFormat('debug');
     $progress->start();
     foreach ($check_directories as $directory) {
         $progress->advance();
         $is_git = $this->checkGit($directory);
         if (!$is_git) {
             $this->checkSvn($directory);
         }
     }
     $progress->finish();
     $this->info('');
     $this->info('Сканирование завершено.');
     $table = [];
     $separator = ['-', '-', '-', '-'];
     if ($this->touched_git) {
         $this->info('Имеются изменные файлы GIT: ');
         foreach ($this->touched_git as $package_path => $files) {
             $package = larasafepath($package_path);
             foreach ($files as $file => $type) {
                 $table[] = ['GIT', $package, larasafepath($file), \Illuminate\Support\Arr::get($this->git_types, $type, $type)];
             }
             $table[] = $separator;
         }
     }
     if ($this->touched_svn) {
         $this->info('Имеются изменные файлы SVN: ');
         foreach ($this->touched_svn as $package_path => $files) {
             $package = larasafepath($package_path);
             foreach ($files as $file => $type) {
                 $table[] = ['SVN', $package, trim(str_replace($package, '', larasafepath($file)), '/'), \Illuminate\Support\Arr::get($this->svn_types, $type, $type)];
             }
             $table[] = $separator;
         }
     }
     if ($table) {
         unset($table[sizeof($table) - 1]);
         $this->info('');
         $this->table(['VCS', 'package', 'file', 'type'], $table);
     }
 }
コード例 #3
0
ファイル: Sync.php プロジェクト: larakit/lk
 protected function dumpTables()
 {
     $this->info('Копирование информации из таблиц');
     $progress = new \Symfony\Component\Console\Helper\ProgressBar($this->output, sizeof($this->tables));
     $progress->setFormat('debug');
     $progress->start();
     foreach ($this->tables as $table) {
         $data = \DB::connection($this->connection_name)->table($table)->get();
         $this->saveTable($table, $data);
         $progress->advance();
     }
     $progress->finish();
     $this->info('');
     $this->info('Таблицы успешно скопированы');
 }
コード例 #4
0
ファイル: CourseService.php プロジェクト: e19940604/Cyinf
 public function autoAddCourse($D0, \Symfony\Component\Console\Output\OutputInterface $output)
 {
     $NormalD1Collect = [["AC1C"], ["AC2K"], ["AC2L"], ["AC2M"], ["AC2N"], [], [], ["AE01", "AE02"], ["AH01"], ["AG01"], [], [], [], [], [], [], [], ["ASE2"], ["B101"], ["B102"], ["B10A"], ["B103"], ["M105"], ["B106"], ["B201"], ["M205"], ["B202"], ["B203"], ["B204"], ["B301"], ["M361"], ["M307"], ["B302"], ["B304"], ["B309"], ["B310"], ["M303"], ["B401"], ["B402"], ["B403"], ["M405"], [], ["B606"], ["M404"], ["M602"], ["M604"], ["B609"], ["M605"], ["M607"], ["B60A"], ["B504"], ["B502"], [], [], ["M507"], [], [], [], ["M462"], [], ["B509"]];
     $SpecialD1Collect = [10 => "AI00", 11 => "AI01", 12 => "AI02", 13 => "AI03", 14 => "AI04", 15 => "AI05", 16 => "AI06", 18 => "M101", 19 => "M102", 21 => "M103", 23 => "M107", 24 => "M201", 26 => "M202", 27 => "M203", 28 => "M204", 29 => "M301", 32 => "M302", 33 => "M304", 34 => "M309", 35 => "M310", 37 => "M411", 38 => "M402", 39 => "M403", 42 => "M606", 46 => "M609", 50 => "M504", 51 => "M502", 60 => "M509"];
     $this->initCourse();
     $bar = new \Symfony\Component\Console\Helper\ProgressBar($output, count($NormalD1Collect) + count($SpecialD1Collect));
     $bar->start();
     foreach ($NormalD1Collect as $course_department => $course_value) {
         foreach ($course_value as $key => $D1) {
             $this->fectch($D0, $D1, $course_department);
         }
         $bar->advance();
     }
     foreach ($SpecialD1Collect as $course_department => $D1) {
         $this->fectch($D0, $D1, $course_department, true);
         $bar->advance();
     }
     $bar->finish();
 }
コード例 #5
0
ファイル: cli-core.php プロジェクト: JackWangCUMT/php.tools
                 } else {
                     file_put_contents($file . '-tmp', $fmtCode);
                     $oldchmod = fileperms($file);
                     $backup && rename($file, $file . '~');
                     rename($file . '-tmp', $file);
                     chmod($file, $oldchmod);
                 }
             }
             $chn_done->in([$cacheHitCount, $cache_miss_count, $filesChanged]);
         }, $fmt, $backup, $cache_fn, $chn, $chn_done, $lintBefore, $dryRun);
     }
 }
 $progress = new \Symfony\Component\Console\Helper\ProgressBar(new \Symfony\Component\Console\Output\StreamOutput(fopen('php://stderr', 'w')), sizeof(iterator_to_array($files)));
 $progress->start();
 foreach ($files as $file) {
     $progress->advance();
     $file = $file[0];
     if (null !== $ignore_list) {
         foreach ($ignore_list as $pattern) {
             if (false !== strpos($file, $pattern)) {
                 continue 2;
             }
         }
     }
     ++$fileCount;
     if ($concurrent) {
         $chn->in(['target_dir' => $target_dir, 'file' => $file]);
     } else {
         if (0 == $fileCount % 20) {
             fwrite(STDERR, ' ' . $fileCount . PHP_EOL);
         }
コード例 #6
0
ファイル: CountryFlags.php プロジェクト: adiachenko/rabbits
 /**
  * Copy provided image to public directory while replacing
  * ISO 3166-1 alpha-3 code in the name with alpha-2 version
  * according to the provided map
  *
  * @param  string $image
  * @param  int $key
  * @param  array $map
  * @return void
  */
 protected function copy($source, $target)
 {
     copy($source, $target);
     $this->progress->advance();
 }
コード例 #7
0
ファイル: benchmark.php プロジェクト: alekitto/serializer
    }
    return $post;
}
$serializer = \Kcs\Serializer\SerializerBuilder::create()->setEventDispatcher(new \Symfony\Component\EventDispatcher\EventDispatcher())->build();
$collection = createCollection();
$metrics = [];
$f = function ($format) use($serializer, $collection) {
    $serializer->serialize($collection, $format);
};
// Load all necessary classes into memory.
$f('array');
$table = new \Symfony\Component\Console\Helper\Table($output);
$table->setHeaders(['Format', 'Direction', 'Time']);
$progressBar = new \Symfony\Component\Console\Helper\ProgressBar($output, 8);
$progressBar->start();
foreach (['array', 'json', 'yml', 'xml'] as $format) {
    $table->addRow([$format, 'serialize', benchmark($f, $format)]);
    $progressBar->advance();
}
$serialized = ['array' => $serializer->serialize($collection, 'array'), 'json' => $serializer->serialize($collection, 'json'), 'yml' => $serializer->serialize($collection, 'yml'), 'xml' => $serializer->serialize($collection, 'xml')];
$type = new \Kcs\Serializer\Type\Type('array', [\Kcs\Serializer\Type\Type::from(\Kcs\Serializer\Tests\Fixtures\BlogPost::class)]);
$d = function ($format) use($serializer, $serialized, $type) {
    $serializer->deserialize($serialized[$format], $type, $format);
};
foreach (['array', 'json', 'yml', 'xml'] as $format) {
    $table->addRow([$format, 'deserialize', benchmark($d, $format)]);
    $progressBar->advance();
}
$progressBar->finish();
$progressBar->clear();
$table->render();