Classes/Application/Command/PatternCommandController.php
/**
     * Generates code with the given pattern in the given package
     *
     * @param string $fileName
     * @param boolean $overwrite
     * @return void
     */
Generates code with the given pattern in the given package
@param string $fileName
@param boolean $overwrite
@return void
Generates code with the given pattern in the given package @param string $fileName @param boolean $overwrite @return void
public function generateCommand(string $fileName, bool $overwrite = false): void
    {
        $this->io->arguments->add([
            'overwrite' => [
                'longPrefix' => 'overwrite',
                'defaultValue' => $overwrite,
                'castTo' => 'bool'
            ]
        ]);
        $this->io->arguments->parse(array_slice($_SERVER['argv'], 3));
        $input = file_get_contents($fileName);
        if ($input = file_get_contents($fileName)) {
            $parser = new Yaml\Parser();
            $data = $parser->parse($input);
            foreach ($data as $item) {
                foreach ($item as $patternKey => $options) {
                    $pattern = $this->patternResolver->resolve($patternKey);
                    $generator = $this->generatorResolver->resolve($pattern);
                    $query = Query::fromArray($options);
                    $this->outputLine();
                    $this->outputLine('<em> Running %s... </em>', [$pattern->getKey()]);
                    $this->outputLine();
                    $generator->generate($query);
                    $this->outputLine();
                }
            }
            $this->outputLine('<success> Done! </success>');
        } else {
            $this->outputLine();
            $this->outputLine('<error> No Input given for %s. </error>');
            $this->outputLine('<em> See ./flow pattern:list a list of patterns. </em>');
            $this->outputLine();
            $this->quit(-1);
        }
    }
public function generateCommand ( string $ fileName , bool $ overwrite = false ) : void { $ this -> io -> arguments -> add ( [ 'overwrite' => [ 'longPrefix' => 'overwrite' , 'defaultValue' => $ overwrite , 'castTo' => 'bool' ] ] ) ; $ this -> io -> arguments -> parse ( array_slice ( $ _SERVER [ 'argv' ] , 3 ) ) ; $ input = file_get_contents ( $ fileName ) ; if ( $ input = file_get_contents ( $ fileName ) ) { $ parser = new Yaml \ Parser ( ) ; $ data = $ parser -> parse ( $ input ) ; foreach ( $ data as $ item ) { foreach ( $ item as $ patternKey => $ options ) { $ pattern = $ this -> patternResolver -> resolve ( $ patternKey ) ; $ generator = $ this -> generatorResolver -> resolve ( $ pattern ) ; $ query = Query :: fromArray ( $ options ) ; $ this -> outputLine ( ) ; $ this -> outputLine ( '<em> Running %s... </em>' , [ $ pattern -> getKey ( ) ] ) ; $ this -> outputLine ( ) ; $ generator -> generate ( $ query ) ; $ this -> outputLine ( ) ; } } $ this -> outputLine ( '<success> Done! </success>' ) ; } else { $ this -> outputLine ( ) ; $ this -> outputLine ( '<error> No Input given for %s. </error>' ) ; $ this -> outputLine ( '<em> See ./flow pattern:list a list of patterns. </em>' ) ; $ this -> outputLine ( ) ; $ this -> quit ( - 1 ) ; } }
Generates code with the given pattern in the given package
 @param string $fileName
 @param boolean $overwrite
 @return void
Generates code with the given pattern in the given package @param string $fileName @param boolean $overwrite @return void