Пример #1
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $cfg = $this->getSelimConfig($input);
     $skippaths = $input->getOption("skip-known-paths") ? true : false;
     $path = realpath($input->getArgument("path"));
     $projects = array();
     $question_helper = $this->getHelper("question");
     $output->write("Start searching _config.php files...");
     $fact = new File_Iterator_Factory();
     $iterator = $fact->getFileIterator($path, "php", "_config");
     $output->writeln("OK");
     $output->write("Filter for project paths...");
     while ($file = $iterator->current()) {
         $content = Util::stripPhpComments(file_get_contents($file));
         if (preg_match("/\\\$project\\s=/", $content)) {
             array_push($projects, dirname($file));
         }
         $iterator->next();
     }
     $output->writeln("OK");
     if (count($projects)) {
         $sites_added = false;
         $output->writeln("found " . count($projects) . " possible sites");
         foreach ($projects as $p) {
             if ($skippaths && $cfg->sitePathExists($p)) {
                 continue;
             }
             $question = new Question("Please enter name for '{$p}' (leave empty to skip)");
             do {
                 $name = $question_helper->ask($input, $output, $question);
             } while ($cfg->siteExists($name));
             if ($name) {
                 $sites_added = true;
                 $cfg->addSite($name, $p);
             }
         }
         if ($sites_added) {
             $output->write("Writing config.json ...");
             $cfg->write();
             $output->writeln("OK");
         }
     }
 }
Пример #2
0
 /**
  * searches for a regex string in PROJECT/_config.php.
  *
  * @param string $regex
  *
  * @return boolean
  */
 private function matchInConfigPhp($regex)
 {
     if ($this->path_configphp) {
         $content = file_get_contents($this->path_configphp);
         $content = Util::stripPhpComments($content);
         $matches = array();
         preg_match_all($regex, $content, $matches);
         return $matches;
     }
     return null;
 }