protected function schemaToXML($checkSchema = self::CHECK_SCHEMA, $prefix = '', $verbose = false)
 {
     $finder = sfFinder::type('file')->name('*schema.yml')->prune('doctrine');
     $dirs = array_merge(array(sfConfig::get('sf_config_dir')), $this->configuration->getPluginSubPaths('/config'));
     $schemas = $finder->in($dirs);
     if (self::CHECK_SCHEMA === $checkSchema && !count($schemas)) {
         throw new sfCommandException('You must create a schema.yml file.');
     }
     $dbSchema = new sfPropelDatabaseSchema();
     foreach ($schemas as $schema) {
         $this->logSection('convert-xml', $schema);
         $schemaArray = sfYaml::load($schema);
         if (!is_array($schemaArray)) {
             continue;
             // No defined schema here, skipping
         }
         if (!isset($schemaArray['classes'])) {
             // Old schema syntax: we convert it
             $schemaArray = $dbSchema->convertOldToNewYaml($schemaArray);
         }
         $customSchemaFilename = str_replace(array(str_replace(DIRECTORY_SEPARATOR, '/', sfConfig::get('sf_root_dir')) . '/', 'plugins/', 'config/', '/', 'schema.yml'), array('', '', '', '_', 'schema.custom.yml'), $schema);
         $customSchemas = sfFinder::type('file')->name($customSchemaFilename)->in($dirs);
         foreach ($customSchemas as $customSchema) {
             if ($verbose) {
                 $this->logSection('schema', sprintf('  found custom schema %s', $customSchema), null, 'COMMENT');
             }
             $customSchemaArray = sfYaml::load($customSchema);
             if (!isset($customSchemaArray['classes'])) {
                 // Old schema syntax: we convert it
                 $customSchemaArray = $dbSchema->convertOldToNewYaml($customSchemaArray);
             }
             $schemaArray = sfToolkit::arrayDeepMerge($schemaArray, $customSchemaArray);
         }
         $dbSchema->loadArray($schemaArray);
         if ($verbose) {
             $this->logSection('schema', sprintf('  converting "%s" to XML', $schema), null, 'COMMENT');
         }
         $localprefix = $prefix;
         // change prefix for plugins
         foreach ($this->configuration->getPlugins() as $plugin) {
             $plugin_config = $this->configuration->getPluginConfiguration((string) $plugin);
             $plugin_root_dir = rtrim($plugin_config->getRootDir(), '/') . '/';
             // if $schema starts with $plugin_root_dir
             if (substr($schema, 0, strlen($plugin_root_dir)) === $plugin_root_dir) {
                 $localprefix = $prefix . $plugin_config->getName() . '-';
                 break;
             }
         }
         // save converted xml files in original directories
         $xml_file_name = str_replace('.yml', '.xml', basename($schema));
         $file = str_replace(basename($schema), $localprefix . $xml_file_name, $schema);
         if ($verbose) {
             $this->logSection('schema', sprintf('  putting %s', $file), null, 'COMMENT');
         }
         file_put_contents($file, $dbSchema->asXML());
     }
 }
 protected function schemaToXML($checkSchema = self::CHECK_SCHEMA, $prefix = '')
 {
     $finder = sfFinder::type('file')->name('*schema.yml')->prune('doctrine');
     $dirs = array_merge(array(sfConfig::get('sf_config_dir')), $this->configuration->getPluginSubPaths('/config'));
     $schemas = $finder->in($dirs);
     if (self::CHECK_SCHEMA === $checkSchema && !count($schemas)) {
         throw new sfCommandException('You must create a schema.yml file.');
     }
     $dbSchema = new sfPropelDatabaseSchema();
     foreach ($schemas as $schema) {
         $schemaArray = sfYaml::load($schema);
         if (!is_array($schemaArray)) {
             continue;
             // No defined schema here, skipping
         }
         if (!isset($schemaArray['classes'])) {
             // Old schema syntax: we convert it
             $schemaArray = $dbSchema->convertOldToNewYaml($schemaArray);
         }
         $customSchemaFilename = str_replace(array(str_replace(DIRECTORY_SEPARATOR, '/', sfConfig::get('sf_root_dir')) . '/', 'plugins/', 'config/', '/', 'schema.yml'), array('', '', '', '_', 'schema.custom.yml'), $schema);
         $customSchemas = sfFinder::type('file')->name($customSchemaFilename)->in($dirs);
         foreach ($customSchemas as $customSchema) {
             $this->logSection('schema', sprintf('found custom schema %s', $customSchema));
             $customSchemaArray = sfYaml::load($customSchema);
             if (!isset($customSchemaArray['classes'])) {
                 // Old schema syntax: we convert it
                 $customSchemaArray = $dbSchema->convertOldToNewYaml($customSchemaArray);
             }
             $schemaArray = sfToolkit::arrayDeepMerge($schemaArray, $customSchemaArray);
         }
         $dbSchema->loadArray($schemaArray);
         $this->logSection('schema', sprintf('converting "%s" to XML', $schema));
         $localprefix = $prefix;
         // change prefix for plugins
         if (preg_match('#plugins[/\\\\]([^/\\\\]+)[/\\\\]#', $schema, $match)) {
             $localprefix = $prefix . $match[1] . '-';
         }
         // save converted xml files in original directories
         $xml_file_name = str_replace('.yml', '.xml', basename($schema));
         $file = str_replace(basename($schema), $localprefix . $xml_file_name, $schema);
         $this->logSection('schema', sprintf('putting %s', $file));
         file_put_contents($file, $dbSchema->asXML());
     }
 }
 /**
  * Update plugin schema
  *
  * @param string $schema_path 
  * @param sfPropelDatabaseSchema $dbSchema 
  * @param string $prefix 
  * @author Sergey Startsev
  */
 private function updatePluginSchema($schema_path, sfPropelDatabaseSchema $dbSchema, $prefix = '')
 {
     $schema_structure_updated = $schema_structure = $this->getSchemaStructure($schema_path);
     $current_schema = $dbSchema->asArray();
     foreach ($schema_structure as $connection => $tables) {
         foreach ($tables as $table_name => $table_structure) {
             if (isset($current_schema[$connection]) && in_array($table_name, $current_schema[$connection])) {
                 $schema_structure_updated[$connection][$table_name] = $table_description;
             }
         }
     }
     if (!empty($prefix)) {
         $schema_path = dirname($schema_path) . "/{$prefix}schema.yml";
     }
     $oSchema = new sfPropelDatabaseSchema();
     $oSchema->loadArray($schema_structure_updated);
     $this->logSection('schema', sprintf('putting %s', $schema_path));
     file_put_contents($schema_path, $oSchema->asYAML());
 }