Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed #5 : Global connection settings #15

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions config/app.yml
Original file line number Diff line number Diff line change
@@ -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"

23 changes: 23 additions & 0 deletions lib/Doctrine/Template/Solr.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand Down
1 change: 1 addition & 0 deletions lib/task/rebuildIndexTask.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
1 change: 1 addition & 0 deletions lib/task/resetIndexTask.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions lib/task/searchTask.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down