Пример #1
0
 /**
  * Create table configurations for all tables that were not configured yet.
  *
  * @param DumperConfigurationInterface $config
  * @param Table[]                      $tables
  */
 private function createMissingTableConfigs(DumperConfigurationInterface $config, array $tables)
 {
     foreach ($tables as $table) {
         if (!$config->hasTableConfig($table->getName())) {
             $config->addTableConfig(new TableConfiguration($table->getName()));
         }
     }
 }
Пример #2
0
 /**
  * Override some variables in the config with parameters from the command line.
  *
  * @param DumperConfigurationInterface $config
  * @param InputInterface               $input
  */
 private function overrideConfigs(DumperConfigurationInterface $config, InputInterface $input)
 {
     if ($input->hasOption('password')) {
         $config->getDatabaseConfig()->setPassword($input->getOption('password'));
     }
     if ($input->getOption('disable-limits')) {
         foreach ($config->getTableConfigs() as $tableConfig) {
             $tableConfig->setLimit(null);
         }
     }
 }
 /**
  * Find dependencies on other tables in the given foreign keys and add those dependencies as filters to the
  * table configuration.
  *
  * @param ForeignKeyConstraint[]       $foreignKeys
  * @param TableConfiguration           $tableConfig
  * @param DumperConfigurationInterface $config
  *
  * @return bool
  */
 private function findDependencies(array $foreignKeys, TableConfiguration $tableConfig, DumperConfigurationInterface $config)
 {
     foreach ($foreignKeys as $foreignKey) {
         $referencedTable = $foreignKey->getForeignTableName();
         $referencedTableConfig = $config->getTableConfig($referencedTable);
         $hasDependency = $referencedTableConfig->getLimit() > 0 || !empty($referencedTableConfig->getFilters()) || $referencedTableConfig->getQuery() != null;
         if ($hasDependency) {
             $tableConfig->addFilter(new DataDependentFilter($foreignKey->getColumns()[0], $referencedTable, $foreignKey->getForeignColumns()[0]));
         }
     }
 }
Пример #4
0
 /**
  * Create a new SqlDataConvert by reading the configuration and adding converters for the sql dumper.
  *
  * @param DumperConfigurationInterface $config
  */
 public function __construct(DumperConfigurationInterface $config)
 {
     foreach ($config->getTableConfigs() as $tableName => $tableConfig) {
         foreach ($tableConfig->getConverters() as $columnName => $converterDefinitions) {
             $key = sprintf('%s.%s', $tableName, $columnName);
             foreach ($converterDefinitions as $converterDefinition) {
                 $converter = $this->createConverterInstance($converterDefinition);
                 $this->addConverter($key, $converter, true);
             }
         }
     }
 }
 /**
  * @param DumperConfigurationInterface $config
  *
  * @return Output|null
  */
 private function createDumpOutputStream(DumperConfigurationInterface $config)
 {
     if (empty($config->getOutputConfig()->getFile())) {
         return null;
         // in this case, the output has to be set via setDumpOutput()
     }
     if ($config->getOutputConfig()->getGzip()) {
         return new GzipStreamOutput(gzopen($config->getOutputConfig()->getFile(), 'w'));
     }
     return new StreamOutput(fopen($config->getOutputConfig()->getFile(), 'w'));
 }