public function loadConfiguration()
 {
     $container = $this->getContainerBuilder();
     $config = $this->getConfig($this->defaults);
     Validators::assert($config['migrationDir'], 'string', 'Migration location directory');
     Validators::assert($config['migrationPrefix'], 'string', 'Migration name prefix');
     Validators::assert($config['options'], 'array', 'Generated SQL options');
     if (!$config['logFile']) {
         $config['logFile'] = FileSystem::normalizePath(sprintf('%s/_schema.txt', $config['migrationDir']));
     }
     $container->addDefinition($this->prefix('repository'))->setClass('Joseki\\Migration\\Database\\Repository', [$config['migrationTable']]);
     $manager = $container->addDefinition($this->prefix('manager'))->setClass('Joseki\\Migration\\Manager', [$config['migrationDir'], $config['migrationPrefix']]);
     $container->addDefinition($this->prefix('command.schema'))->setClass('Joseki\\Migration\\Console\\Command\\Schema', [$config['logFile']])->addTag(self::TAG_JOSEKI_COMMAND)->addTag(self::TAG_KDYBY_COMMAND);
     $container->addDefinition($this->prefix('command.create'))->setClass('Joseki\\Migration\\Console\\Command\\Create')->addTag(self::TAG_JOSEKI_COMMAND)->addTag(self::TAG_KDYBY_COMMAND);
     $container->addDefinition($this->prefix('command.migrate'))->setClass('Joseki\\Migration\\Console\\Command\\Migrate')->addTag(self::TAG_JOSEKI_COMMAND)->addTag(self::TAG_KDYBY_COMMAND);
     $container->addDefinition($this->prefix('platform'))->setClass('Doctrine\\DBAL\\Platforms\\MySqlPlatform');
     $container->addDefinition($this->prefix('generator.lm'))->setClass('Joseki\\Migration\\Generator\\LeanMapperSchemaGenerator', [$config['options']]);
     foreach ($this->getFiles($config['migrationDir']) as $index => $class) {
         if (!($class = $this->resolveRealClassName($class))) {
             continue;
         }
         $name = $this->prefix('migration.' . $index);
         $container->addDefinition($name)->setClass($class)->setInject(false)->setAutowired(false);
         $manager->addSetup('add', ['@' . $name]);
     }
 }
 public function saveToDirectory($path)
 {
     $dir = rtrim($path, '/');
     @mkdir($dir, 0755, true);
     $filename = FileSystem::normalizePath($dir . '/' . $this->getFullName() . '.php');
     file_put_contents($filename, $this->__toString());
     return $filename;
 }
Beispiel #3
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $schema = $this->schemaList[$this->selectedSchema];
     $schema->resolveVariables();
     $dir = $this->rootDir . '/' . $this->selectedDir;
     foreach ($schema->getFiles() as $var => $templatePath) {
         $fileName = $dir . '/' . $schema->getVariable($var);
         @mkdir(dirname($fileName), 0777, true);
         $content = $schema->translate(file_get_contents($templatePath));
         file_put_contents($fileName, $content);
         $output->writeln('Created file: ' . FileSystem::normalizePath($fileName));
     }
 }