~fabiocbalbuquerque/sahana-agasti/web-services

« back to all changes in this revision

Viewing changes to plugins/ajDoctrineLuceneablePlugin/lib/task/luceneOptimizeTask.class.php

Adding ajDoctrineLuceneablePlugin

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
 
 
3
class luceneOptimizeTask extends sfBaseTask
 
4
{
 
5
  protected function configure()
 
6
  {
 
7
 
 
8
    $this->addOptions(array(
 
9
      new sfCommandOption('application', null, sfCommandOption::PARAMETER_OPTIONAL, 'The application name', true),
 
10
      new sfCommandOption('env', null, sfCommandOption::PARAMETER_REQUIRED, 'The environment', 'dev'),
 
11
      new sfCommandOption('connection', null, sfCommandOption::PARAMETER_REQUIRED, 'The connection name', 'default'),
 
12
      // add your own options here
 
13
    ));
 
14
 
 
15
    $this->namespace        = 'lucene';
 
16
    $this->name             = 'optimize';
 
17
    $this->briefDescription = 'Optimize a lucene index';
 
18
    $this->detailedDescription = <<<EOF
 
19
The [lucene:optimize|INFO] optimizes the lucene index
 
20
Call it with:
 
21
symfony lucene:optimize
 
22
 
 
23
  [php symfony lucene:optimize|INFO]
 
24
EOF;
 
25
  }
 
26
 
 
27
  protected function execute($arguments = array(), $options = array())
 
28
  {
 
29
    sfContext::createInstance($this->configuration);
 
30
    $timer = new sfTimer('timer');
 
31
     $this->log('Optimizing ' . LuceneHandler::getLuceneIndexFile() );
 
32
    $index = LuceneHandler::getLuceneIndex();
 
33
    $index->optimize();
 
34
    $this->log('Optimizing took '. round($timer->getElapsedTime(),2) . ' seconds');
 
35
  }
 
36
}