Permalink
Browse files

Merge pull request #214 from mheiniger/speedupFixtureLoader

Speedup propel:fixture:load
  • Loading branch information...
2 parents b07aee0 + bfc8892 commit ea98e9c18dda36406acd2762d8d7da1321d4d23d @havvg havvg committed May 23, 2013
@@ -64,7 +64,7 @@ protected function loadMapBuilders($connectionName = null)
if (0 === count($this->dbMap->getTables())) {
$finder = new Finder();
$files = $finder->files()->name('*TableMap.php')
- ->in($this->getRootDir() . '/../')
+ ->in($this->getModelSearchPaths($connectionName))
->exclude('PropelBundle')
->exclude('Tests');
@@ -120,4 +120,27 @@ private function guessFullClassName($path, $shortClassName)
return null;
}
+
+ /**
+ * Gets the search path for models out of the configuration.
+ *
+ * @param string $connectionName A connection name.
+ *
+ * @return string[]
+ */
+ protected function getModelSearchPaths($connectionName) {
+ $configuration = Propel::getConfiguration();
+ $searchPath = array();
+
+ if (!empty($configuration['datasources'][$connectionName]['connection']['model_paths'])) {
+ $modelPaths = $configuration['datasources'][$connectionName]['connection']['model_paths'];
+ foreach ($modelPaths as $modelPath) {
+ $searchPath[] = $this->getRootDir() . '/../' . $modelPath;
+ }
+ } else {
+ $searchPath[] = $this->getRootDir() . '/../';
+ }
+
+ return $searchPath;
+ }
}
@@ -232,6 +232,13 @@ private function getDbalConnectionsNode()
->prototype('scalar')->end()
->end()
->end()
+ ->fixXmlConfig('model_path')
+ ->children()
+ ->arrayNode('model_paths')
+ ->defaultValue(array('src/', 'vendor/'))
+ ->prototype('scalar')->end()
+ ->end()
+ ->end()
->fixXmlConfig('attribute')
->children()
->arrayNode('attributes')
@@ -123,7 +123,7 @@ protected function dbalLoad(array $config, ContainerBuilder $container)
$c['datasources'][$name]['slaves']['connection'] = $conf['slaves'];
}
- foreach (array('dsn', 'user', 'password', 'classname', 'options', 'attributes', 'settings') as $att) {
+ foreach (array('dsn', 'user', 'password', 'classname', 'options', 'attributes', 'settings', 'model_paths') as $att) {
if (isset($conf[$att])) {
$c['datasources'][$name]['connection'][$att] = $conf[$att];
}
@@ -110,10 +110,13 @@ propel:
settings:
charset: { value: UTF8 }
queries: { query: 'INSERT INTO BAR ('hey', 'there')' }
+ model_paths:
+ - /src/Acme/DemoBundle/Model/
+ - /vendor/
```
`options`, `attributes` and `settings` are parts of the runtime configuration. See [Runtime Configuration File](http://www.propelorm.org/reference/runtime-configuration.html) documentation for more explanation.
-
+`model_paths` can be defined to speed up searching for model data. By default it searches in the whole project from project root.
## Logging ##

0 comments on commit ea98e9c

Please sign in to comment.