/** * Getting schemas array from configs * * @return array - Connections and tables * @author Sergey Startsev */ private static function getSchemas() { $aPropelSchemaArray = array(); $configuration = new ProjectConfiguration(null, new sfEventDispatcher()); $db_schema = new sfPropelDatabaseSchema(); $dirs = array_merge(array(sfConfig::get('sf_config_dir')), $configuration->getPluginSubPaths('/config')); foreach ($dirs as $k => $dir) { if (substr_count($dir, 'appFlower') > 0 || substr_count($dir, 'sfPropelPlugin') > 0 || substr_count($dir, 'sfProtoculousPlugin') > 0) { unset($dirs[$k]); } } $dirs = array_values($dirs); $schemas = sfFinder::type('file')->name('*schema.yml')->prune('doctrine')->in($dirs); foreach ($schemas as $schema_path) { $schema = DIRECTORY_SEPARATOR != '/' ? str_replace('/', DIRECTORY_SEPARATOR, $schema_path) : $schema_path; $aOriginalSchemaArray[$schema] = sfYaml::load($schema); if (!is_array($aOriginalSchemaArray[$schema])) { $aOriginalSchemaArray[$schema]; continue; // No defined schema here, skipping } if (!isset($aOriginalSchemaArray[$schema]['classes'])) { // Old schema syntax: we convert it $aPropelSchemaArray[$schema] = $db_schema->convertOldToNewYaml($aOriginalSchemaArray[$schema]); } $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) { $aOriginalSchemaArray[$customSchema] = sfYaml::load($customSchema); if (!isset($aOriginalSchemaArray[$customSchema]['classes'])) { // Old schema syntax: we convert it $aPropelSchemaArray[$customSchema] = $db_schema->convertOldToNewYaml(${$aOriginalSchemaArray}[$customSchema]); } } } return $aPropelSchemaArray; }