コード例 #1
0
 /**
  * Execute the command
  *
  * @param Symfony\Component\Console\Input\InputInterface $input, Symfony\Component\Console\Output\OutputInterface $output
  * @return void
  */
 public function execute(InputInterface $input, OutputInterface $output)
 {
     $output->writeln('<info>Working...</info>');
     $output->writeln('<info>This may take a few minutes</info>');
     $handle = $this->transcriber->loadCmuFile();
     $this->makeOptions();
     $this->setOptionsField('destination', $input->getOption('destination'));
     $this->setOptionsField('fields', explodeByComma($input->getOption('fields')));
     $this->setOptionsField('file_name', $input->getOption('file'));
     $this->setOptionsField('multiple', $input->getOption('multiple'));
     $this->setOptionsField('symbol', $input->getOption('symbol'));
     $this->setOptionsField('method_names', $this->builder->buildFieldMethods($this->options['fields']));
     if (!$handle) {
         $GLOBALS['status'] = 1;
         die('<error>File did not open properly</error>');
     }
     $destination_method = $this->builder->buildAllDestinationMethod($this->options['destination']);
     if (!method_exists($this, $destination_method)) {
         $output->writeln("<error>Incorret destination input</error>");
         $output->writeln("<info>Destination options: </info><comment>file,database</comment>");
         $GLOBALS['status'] = 1;
         return null;
     }
     $this->{$destination_method}($output, $handle);
 }
コード例 #2
0
 /**
  * Execute the command
  *
  * @param Symfony\Component\Console\Input\InputInterface $input, Symfony\Component\Console\Output\OutputInterface $output
  * @return void
  */
 public function execute(InputInterface $input, OutputInterface $output)
 {
     $output->writeln('<info>Searching...</info>');
     $handle = $this->transcriber->loadCmuFile();
     $strings = explodeByComma($input->getArgument('word'));
     $this->makeOptions();
     $this->setOptionsField('destination', $input->getOption('destination'));
     $this->setOptionsField('fields', explodeByComma($input->getOption('fields')));
     $this->setOptionsField('file_name', $input->getOption('file'));
     $this->setOptionsField('hyphenate', $input->getOption('hyphenate'));
     $this->setOptionsField('multiple', $input->getOption('multiple'));
     $this->setOptionsField('symbol', $input->getOption('symbol'));
     $this->setOptionsField('method_names', $this->builder->buildFieldMethods($this->options['fields']));
     if (!$handle) {
         $GLOBALS['status'] = 1;
         die('<error>File did not open properly</error>');
     }
     $answers = [];
     $answered = [];
     while (($line = fgets($handle)) !== false) {
         if (isComment($line)) {
             continue;
         }
         $exploded_line = explode(' ', $line);
         $word = trim($exploded_line[0]);
         $word = $this->parseDuplicateEntries($word);
         if (in_array($word, $strings)) {
             $output_word = $this->hyphenateOutputWord($this->hyphenator, $word);
             $output_word = $this->setHyphenationSymbol($output_word);
             $key = $this->makeAnswersKey($word, $answers);
             $answers[$key] = $this->makeLookupOutputArray($output, $output_word, $exploded_line);
             array_push($answered, $word);
         }
     }
     if ($GLOBALS['status'] !== 0) {
         return null;
     }
     $unanswered = array_diff($strings, $answered);
     $destination_method = $this->builder->buildDestinationMethod($this->options['destination']);
     if (!method_exists($this, $destination_method)) {
         $output->writeln("<error>Incorret destination input</error>");
         $output->writeln("<info>Destination options: </info><comment>table,string,file,database</comment>");
         $GLOBALS['status'] = 1;
         return null;
     }
     $this->{$destination_method}($output, $answers);
     $this->displayErrorForUnanswered($output, $unanswered);
     fclose($handle);
 }
コード例 #3
0
 /**
  * Execute the command
  *
  * @param Symfony\Component\Console\Input\InputInterface $input, Symfony\Component\Console\Output\OutputInterface $output
  * @return void
  */
 public function execute(InputInterface $input, OutputInterface $output)
 {
     $output->writeln('<info>Hyphenating...</info>');
     $words = explodeByComma($input->getArgument('word'));
     $this->makeOptions();
     $this->setOptionsField('destination', $input->getOption('destination'));
     $this->setOptionsField('file_name', $input->getOption('file'));
     $this->setOptionsField('symbol', $input->getOption('symbol'));
     $answers = [];
     foreach ($words as $word) {
         $hyphenated_word = $this->hyphenator->hyphenateWord($word);
         $hyphenated_word = $this->setHyphenationSymbol($hyphenated_word);
         $answers[$word] = $this->makeHyphenateOutputArray($word, $hyphenated_word);
     }
     $destination_method = $this->builder->buildDestinationMethod($this->options['destination']);
     if (!method_exists($this, $destination_method)) {
         $output->writeln("<error>Incorret destination input</error>");
         $output->writeln("<info>Destination options: </info><comment>table,string,file,database</comment>");
         $GLOBALS['status'] = 1;
         return null;
     }
     $this->{$destination_method}($output, $answers);
 }