diff --git a/config/app.yml b/config/app.yml new file mode 100644 index 0000000..36df280 --- /dev/null +++ b/config/app.yml @@ -0,0 +1,15 @@ +# solr default config +all: + solr: +# models: +# TableName: +# index: +# host: "localhost" +# port: "8983" +# path: "/solr" + + index: + host: "localhost" + port: "8983" + path: "/solr" + diff --git a/lib/Doctrine/Template/Solr.php b/lib/Doctrine/Template/Solr.php index 617738c..ba7526c 100644 --- a/lib/Doctrine/Template/Solr.php +++ b/lib/Doctrine/Template/Solr.php @@ -35,6 +35,29 @@ public function setTableDefinition() public function setUp() { + $table = get_class($this->getInvoker()); + + try { + if (class_exists('sfConfig', false)) { + $index = sfConfig::get('app_solr_index', false); + $models = sfConfig::get('app_solr_models', array()); + + foreach (array('host', 'port', 'path') as $param) { + if (!empty($models[$table]['index'][$param])) { + $this->_options[$param] = $models[$table]['index'][$param]; + } + else if (!empty($index[$param])) { + $this->_options[$param] = $index[$param]; + } + } + } + } + catch (Exception $e) { + if (class_exists('sfContext', false) && sfContext::hasInstance()) { + sfContext::getInstance()->getLogger()->crit('{Doctrine_Template_Solr::setUp} Error while setting up solr : '.$e->getMessage()); + } + } + $searchHandler = new Search_Handler_Solr( $this->_options['host'], $this->_options['port'], diff --git a/lib/task/rebuildIndexTask.class.php b/lib/task/rebuildIndexTask.class.php index 72507a2..a89655b 100644 --- a/lib/task/rebuildIndexTask.class.php +++ b/lib/task/rebuildIndexTask.class.php @@ -23,6 +23,7 @@ protected function configure() )); $this->addOptions(array( + new sfCommandOption('application', null, sfCommandOption::PARAMETER_REQUIRED, 'The application name', 'frontend'), new sfCommandOption('env', null, sfCommandOption::PARAMETER_REQUIRED, 'The environment', 'dev'), new sfCommandOption('connection', null, sfCommandOption::PARAMETER_REQUIRED, 'The connection name', null), new sfCommandOption('offset', null, sfCommandOption::PARAMETER_REQUIRED, 'The offset', 0), diff --git a/lib/task/resetIndexTask.class.php b/lib/task/resetIndexTask.class.php index df1d65b..b042b78 100644 --- a/lib/task/resetIndexTask.class.php +++ b/lib/task/resetIndexTask.class.php @@ -22,6 +22,7 @@ protected function configure() )); $this->addOptions(array( + new sfCommandOption('application', null, sfCommandOption::PARAMETER_REQUIRED, 'The application name', 'frontend'), new sfCommandOption('env', null, sfCommandOption::PARAMETER_REQUIRED, 'The environment', 'dev'), new sfCommandOption('connection', null, sfCommandOption::PARAMETER_REQUIRED, 'The connection name', null), // add your own options here diff --git a/lib/task/searchTask.class.php b/lib/task/searchTask.class.php index 8b8effa..24a97fe 100644 --- a/lib/task/searchTask.class.php +++ b/lib/task/searchTask.class.php @@ -22,6 +22,7 @@ protected function configure() )); $this->addOptions(array( + new sfCommandOption('application', null, sfCommandOption::PARAMETER_REQUIRED, 'The application name', 'frontend'), new sfCommandOption('env', null, sfCommandOption::PARAMETER_REQUIRED, 'The environment', 'dev'), new sfCommandOption('connection', null, sfCommandOption::PARAMETER_REQUIRED, 'The connection name', null), new sfCommandOption('start', null, sfCommandOption::PARAMETER_REQUIRED, 'The search offset', 0),