Beispiel #1
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $generatorConfig = new GeneratorConfig(array('propel.platform.class' => $input->getOption('platform'), 'propel.builder.peer.class' => $input->getOption('peer-class'), 'propel.builder.peerstub.class' => $input->getOption('peer-stub-class'), 'propel.builder.object.class' => $input->getOption('object-class'), 'propel.builder.objectstub.class' => $input->getOption('object-stub-class'), 'propel.builder.objectmultiextend.class' => $input->getOption('object-multiextend-class'), 'propel.builder.query.class' => $input->getOption('query-class'), 'propel.builder.querystub.class' => $input->getOption('query-stub-class'), 'propel.builder.queryinheritance.class' => $input->getOption('query-inheritance-class'), 'propel.builder.queryinheritancestub.class' => $input->getOption('query-inheritance-stub-class'), 'propel.builder.tablemap.class' => $input->getOption('tablemap-class'), 'propel.builder.pluralizer.class' => $input->getOption('pluralizer-class'), 'propel.disableIdentifierQuoting' => !$input->getOption('enable-identifier-quoting'), 'propel.targetPackage' => $input->getOption('target-package'), 'propel.packageObjectModel' => $input->getOption('enable-package-object-model'), 'propel.namespace.autoPackage' => !$input->getOption('disable-namespace-auto-package'), 'propel.basePrefix' => $input->getOption('base-prefix'), 'propel.addGenericAccessors' => true, 'propel.addGenericMutators' => true, 'propel.addSaveMethod' => true, 'propel.addTimeStamp' => false, 'propel.addValidateMethod' => true, 'propel.addHooks' => true, 'propel.namespace.om' => 'Om', 'propel.namespace.map' => 'Map', 'propel.useLeftJoinsInDoJoinMethods' => true, 'propel.emulateForeignKeyConstraints' => false, 'propel.schema.autoPrefix = false' => false, 'propel.dateTimeClass' => '\\DateTime', 'propel.mysql.tableType' => $input->getOption('mysql-engine'), 'propel.mysql.tableEngineKeyword' => 'ENGINE'));
     $filesystem = new Filesystem();
     $filesystem->mkdir($input->getOption('output-dir'));
     $manager = new ModelManager();
     $manager->setGeneratorConfig($generatorConfig);
     $manager->setSchemas($this->getSchemas($input));
     $manager->setLoggerClosure(function ($message) use($input, $output) {
         if ($input->getOption('verbose')) {
             $output->writeln($message);
         }
     });
     $manager->setWorkingDirectory($input->getOption('output-dir'));
     $manager->build();
 }
Beispiel #2
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $generatorConfig = new GeneratorConfig(array('propel.platform.class' => $input->getOption('platform'), 'propel.database.schema' => $input->getOption('schema-name'), 'propel.database.encoding' => $input->getOption('encoding'), 'propel.tablePrefix' => $input->getOption('table-prefix'), 'propel.useLeftJoinsInDoJoinMethods' => true, 'propel.mysql.tableType' => $input->getOption('mysql-engine'), 'propel.mysql.tableEngineKeyword' => 'ENGINE'));
     $filesystem = new Filesystem();
     $filesystem->mkdir($input->getOption('output-dir'));
     $manager = new SqlManager();
     $manager->setValidate($input->getOption('validate'));
     $manager->setGeneratorConfig($generatorConfig);
     $manager->setSchemas($this->getSchemas($input));
     $manager->setLoggerClosure(function ($message) use($input, $output) {
         if ($input->getOption('verbose')) {
             $output->writeln($message);
         }
     });
     $manager->setWorkingDirectory($input->getOption('output-dir'));
     $manager->buildSql();
 }
Beispiel #3
0
 /**
  * Uses a builder class to create the output class.
  * This method assumes that the DataModelBuilder class has been initialized with the build properties.
  *
  * @param      \Propel\Generator\Builder\Om\AbstractOMBuilder $builder
  * @param      boolean $overwrite Whether to overwrite existing files with te new ones (default is YES).
  */
 protected function doBuild(AbstractOMBuilder $builder, $overwrite = true)
 {
     $path = $builder->getClassFilePath();
     $file = new \SplFileInfo($this->getWorkingDirectory() . DIRECTORY_SEPARATOR . $path);
     $filesystem = new Filesystem();
     $filesystem->mkdir($file->getPath());
     // skip files already created once
     if ($file->isFile() && !$overwrite) {
         $this->log("\t-> (exists) " . $builder->getClassFilePath());
         return 0;
     }
     $script = $builder->build();
     foreach ($builder->getWarnings() as $warning) {
         $this->log($warning);
     }
     // skip unchanged files
     if ($file->isFile() && $script == file_get_contents($file->getPathname())) {
         $this->log("\t-> (unchanged) " . $builder->getClassFilePath());
         return 0;
     }
     // write / overwrite new / changed files
     $action = $file->isFile() ? 'Updating' : 'Creating';
     $this->log(sprintf("\t-> %s %s (table: %s, builder: %s)", $action, $builder->getClassFilePath(), $builder->getTable()->getName(), get_class($builder)));
     file_put_contents($file->getPathname(), $script);
     return 1;
 }