Example #1
0
 /**
  * @see Console\Command\Command
  */
 protected function initialize(InputInterface $input, OutputInterface $output)
 {
     $project = $this->getApplication()->getProject();
     if (true === $input->hasParameterOption(array('--path', '-p'))) {
         #switch path to the argument
         $project->getPath()->parse((string) $input->getOption('path'));
         # change the extension directories
         $project['loader']->setExtensionNamespace('Faker\\Extension', $project->getPath()->get());
     }
     #try and detect if path exits
     $path = $project->getPath()->get();
     if ($path === false) {
         throw new \RuntimeException('Project Folder does not exist');
     }
     # path exists does it have a project
     if (Project::detect((string) $path) === false && $this->getName() !== 'faker:init') {
         throw new \RuntimeException('Project Folder does not contain the correct folder heirarchy');
     }
     # load the extension bootstrap the path has been verifed to contain an extension folder
     if ($this->getName() !== 'faker:init') {
         $project->getPath()->loadExtensionBootstrap();
     }
     if (true === $input->hasParameterOption(array('--schema'))) {
         #switch path to the argument
         $project['schema_name'] = $input->getOption('schema');
     }
     # Test for DSN
     if (true === $input->hasParameterOption(array('--dsn'))) {
         $project['dsn_command'] = $input->getOption('dsn');
     }
     parent::initialize($input, $output);
 }