コード例 #1
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $environments = explode(',', $input->getArgument('environments'));
     $table = (new Table($output))->setHeaders(['env', 'key', 'value']);
     foreach ($environments as $key => $environment) {
         if ($key > 0) {
             $table->addRow(new TableSeparator());
         }
         $environmentKernel = new \AppKernel($environment, false);
         $environmentKernel->initializeWithoutCaching();
         foreach ($environmentKernel->getContainer()->getParameterBag()->all() as $parameter => $value) {
             if ($input->getOption('filter') !== null) {
                 $pattern = sprintf('~%s~', $input->getOption('filter'));
                 if (!preg_match($pattern, $parameter)) {
                     continue;
                 }
             }
             if (is_array($value)) {
                 $value = json_encode($value);
             }
             $table->addRow([$environment, $parameter, $value]);
         }
     }
     $table->render();
 }