22
* An event-driven way to index models related to a specific event
23
* @param sfEvent $event A symfony event
24
22
* @param boolean $reset by default is 0, meaning the entire index is rewritten.
23
* @todo maybe refactor to do all this stuff by reference? -UA
26
25
public static function indexAll(sfEvent $event = null, $reset = 0)
28
ignore_user_abort(true);
28
32
if (isset($event)) {
29
33
$action = $event->getSubject();
40
self::indexModels($models, $context, $reset);
44
* Reindexes models passed in the $models array
45
* @param array $models An array of models to reindex
46
* @param sfContext $context The sfContext instance to use
47
* @param boolean $reset by default is 0, meaning the entire index is rewritten.
48
* @todo maybe refactor to do all this stuff by reference? -UA
50
public static function indexModels(array $models, sfContext $context = NULL, $reset = 0)
52
ignore_user_abort(true);
55
if (is_null($context)) {
56
$context = sfContext::getInstance();
59
44
$dispatcher = $context->getEventDispatcher();
60
45
$task = new luceneReindexTask($dispatcher, new sfFormatter());
47
// "Tricks" plugin into thinking we're in a project directory
62
48
$oldDir = getcwd();
64
// "Tricks" plugin into thinking we're in a project directory
65
chdir(sfConfig::get('sf_root_dir'));
67
foreach ($models as $indexModel) {
69
array('model' => $indexModel),
73
'connection' => 'doctrine',
74
'application' => 'frontend'
49
chdir(sfConfig::get('sf_root_dir'));
52
foreach ($models as $indexModel) {
54
array('model' => $indexModel),