move default values into configuration
This commit is contained in:
parent
c043dbb027
commit
c71d4f9fb1
|
@ -64,7 +64,7 @@ abstract class AbstractDataHandler
|
||||||
if (0 === count($this->dbMap->getTables())) {
|
if (0 === count($this->dbMap->getTables())) {
|
||||||
$finder = new Finder();
|
$finder = new Finder();
|
||||||
$files = $finder->files()->name('*TableMap.php')
|
$files = $finder->files()->name('*TableMap.php')
|
||||||
->in($this->getModelSearchPath($connectionName))
|
->in($this->getModelSearchPaths($connectionName))
|
||||||
->exclude('PropelBundle')
|
->exclude('PropelBundle')
|
||||||
->exclude('Tests');
|
->exclude('Tests');
|
||||||
|
|
||||||
|
@ -122,23 +122,25 @@ abstract class AbstractDataHandler
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the search path for models out of the configuration.
|
* Gets the search path for models out of the configuration.
|
||||||
*
|
*
|
||||||
* @param string $connectionName A connection name.
|
* @param string $connectionName A connection name.
|
||||||
*/
|
*
|
||||||
|
* @return string[]
|
||||||
private function getModelSearchPath($connectionName) {
|
*/
|
||||||
|
protected function getModelSearchPaths($connectionName) {
|
||||||
$configuration = Propel::getConfiguration();
|
$configuration = Propel::getConfiguration();
|
||||||
$searchPath = array();
|
$searchPath = array();
|
||||||
|
|
||||||
if (!empty($configuration['datasources'][$connectionName]['connection']['model_paths'])) {
|
if (!empty($configuration['datasources'][$connectionName]['connection']['model_paths'])) {
|
||||||
$modelPaths = $configuration['datasources'][$connectionName]['connection']['model_paths'];
|
$modelPaths = $configuration['datasources'][$connectionName]['connection']['model_paths'];
|
||||||
foreach ($modelPaths as $modelPath) {
|
foreach ($modelPaths as $modelPath) {
|
||||||
$searchPath[] = $this->getRootDir() . '/../' . $modelPath;
|
$searchPath[] = $this->getRootDir() . '/../' . $modelPath;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$searchPath[] = $this->getRootDir() . '/../src/';
|
$searchPath[] = $this->getRootDir() . '/../';
|
||||||
$searchPath[] = $this->getRootDir() . '/../vendor/';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $searchPath;
|
return $searchPath;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -235,6 +235,7 @@ class Configuration implements ConfigurationInterface
|
||||||
->fixXmlConfig('model_path')
|
->fixXmlConfig('model_path')
|
||||||
->children()
|
->children()
|
||||||
->arrayNode('model_paths')
|
->arrayNode('model_paths')
|
||||||
|
->defaultValue(array('src/', 'vendor/'))
|
||||||
->prototype('scalar')->end()
|
->prototype('scalar')->end()
|
||||||
->end()
|
->end()
|
||||||
->end()
|
->end()
|
||||||
|
|
Loading…
Reference in a new issue