Development

Changeset 6771

You must first sign up to be able to contribute.

Changeset 6771

Show
Ignore:
Timestamp:
12/27/07 21:01:54 (1 year ago)
Author:
Carl.Vondrick
Message:

Reinstated camel case for indexes. If you had "superDuperMan" in a fields or categories parameter, you now *must* make the declaration "super_duper_man"

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • plugins/sfLucenePlugin/branches/1.1/CHANGELOG

    r6657 r6771  
    1414  * Upgraded forms to sfForm 
    1515  * Fixed sfLucene does not handle changed categories (closes #2687) 
     16  * BC: Reinstated camel case for indexes.  If you had "superDuperMan" in a 
     17    fields or categories parameter, you now *must* make the declaration 
     18    "super_duper_man". 
    1619 
    1720Version 0.1.1 Beta 
  • plugins/sfLucenePlugin/branches/1.1/README

    r6733 r6771  
    1111= Main Features = 
    1212  * Configured all by YAML files 
    13   * Complete integration with symfony 
     13  * Complete integration with symfony 1.1 
    1414  * i18n ready 
    1515  * Keyword highlighting 
    16   * Stop words, short words 
    17   * Index optimization 
    18   * Custom indexers 
    19   * Multiple indexes 
    20   * Extensible 
     16  * Management of Lucene indexes 
     17  * 500+ unit tests and 98% API code coverage 
    2118 
    2219= Development Status = 
     
    116113When search results are displayed, the system intelligently guesses which field should be displayed as the result "title" and which field is the result "description." However, to be explicit, you can specify a description and title field, as in BlogComment. 
    117114 
    118 Note that the fields do not have to exist as fields in your database.  As long as it has a getter on the model, you can use it in your index. 
     115Note that the fields do not have to exist as fields in your database.  As long as it has a getter on the model, you can use it in your index.  The fields are automatically camelized, so if you wish to call "->getSuperDuperMan()" as one of your fieds, you must write it in the YAML file as "super_duper_man". 
    119116 
    120117See [http://framework.zend.com/manual/en/zend.search.lucene.html the Zend_Search_Lucene documentation] for more about the field types. 
     
    180177  models: 
    181178    BlogPost: 
    182       validator: shouldIndex 
     179      validator: should_index 
    183180}}} 
    184181 
     
    404401The "Blog" model above will be placed both into the blog category and the string returned by ->getCategory() on the model. After you rebuild your model, a category drop down will automatically appear on the search interface. 
    405402 
     403The same rules applies as model indexing: Note that the fields do not have to exist as fields in your database.  As long as it has a getter on the model, you can use it in your index.  The fields are automatically camelized, so if you wish to call "->getSuperDuperMan()" as one of your fieds, you must write it in the YAML file as "super_duper_man". 
     404 
    406405To disable category support all-together, open the application level app.yml file and add: 
    407406 
  • plugins/sfLucenePlugin/branches/1.1/lib/indexer/sfLucenePropelIndexer.class.php

    r6695 r6771  
    105105      $field_properties = $properties->get('fields')->get($field); 
    106106 
    107       $getter = 'get' . $field
     107      $getter = 'get' . sfInflector::camelize($field)
    108108 
    109109      $type = $field_properties->get('type'); 
     
    192192    $properties = $this->getModelProperties(); 
    193193    $method = $properties->get('validator'); 
     194    $method = sfInflector::camelize($method); 
    194195 
    195196    if ($method && method_exists($this->getModel(), $method)) 
     
    218219        $category = substr($category, 1, -1); 
    219220 
    220         $getter = 'get' . $category
     221        $getter = 'get' . sfInflector::camelize($category)
    221222 
    222223        $getterValue = $this->getModel()->$getter(); 
  • plugins/sfLucenePlugin/branches/1.1/lib/results/sfLuceneModelResult.class.php

    r6687 r6771  
    5151    if (!$model->has('route')) 
    5252    { 
    53       throw new sfLuceneIndexerException(sprintf('A route for model "%s" was not defined in the search.yml file.', $this->getInternalModel())); 
     53      throw new sfLuceneIndexerException(sprintf('A route for model "%s" was not defined.', $this->getInternalModel())); 
    5454    } 
    5555 
    56     return preg_replace_callback('/%(\w+?)%/', array($this, 'internalUriCallback'), $model->get('route')); 
    57   } 
    58  
    59   /** 
    60   * Callback for self::getInternalUri() 
    61   */ 
    62   protected function internalUriCallback($matches) 
    63   { 
    64     return $this->result->getDocument()->getFieldValue($matches[1]); 
     56    return preg_replace('/%(\w+?)%/e', '$this->result->getDocument()->getFieldValue("$1")', $model->get('route')); 
    6557  } 
    6658 
  • plugins/sfLucenePlugin/branches/1.1/lib/results/sfLuceneResult.class.php

    r6685 r6771  
    138138  { 
    139139    $property = substr($method, strlen($prefix)); 
    140     $property = strtolower($property)
     140    $property = $property
    141141 
    142     if (substr($property, 0, 8) == 'internal') 
     142    if (strtolower(substr($property, 0, 8)) == 'internal') 
    143143    { 
    144       $property = 'sfl_' . substr($property, 8); 
     144      $property = 'sfl_' . sfInflector::underscore(substr($property, 8)); 
     145    } 
     146    else 
     147    { 
     148      $property = sfInflector::underscore($property); 
    145149    } 
    146150 
  • plugins/sfLucenePlugin/branches/1.1/test/unit/indexer/sfLucenePropelIndexerTest.php

    r6696 r6771  
    161161$indexer->delete(); 
    162162$h->get('fields')->remove('nonScalar'); 
    163 $h->get('fields')->set('stringableObject', $ph); 
     163$h->get('fields')->set('stringable_object', $ph); 
    164164 
    165165try { 
     
    167167  $lucene->commit(); 
    168168  $doc = getDoc($lucene, $indexer->getModelGuid()); 
    169   $t->is($doc->stringableobject, 'Strings!', '->insert() converts objects to strings in field getters'); 
     169  $t->is($doc->stringable_object, 'Strings!', '->insert() converts objects to strings in field getters'); 
    170170} catch (Exception $e) { 
    171171  $t->fail('->insert() converts objects to strings in field getters'); 
     
    346346} 
    347347 
    348 $h->set('categories', array('Forum', '%stringableObject%')); 
     348$h->set('categories', array('Forum', '%stringable_object%')); 
    349349 
    350350$indexer->delete(); 
  • plugins/sfLucenePlugin/branches/1.1/test/unit/results/sfLuceneResultTest.php

    r6685 r6771  
    1717require dirname(__FILE__) . '/../../bootstrap/unit.php'; 
    1818 
    19 $t = new lime_test(21, new lime_output_color()); 
     19$t = new lime_test(23, new lime_output_color()); 
    2020 
    2121$lucene = sfLucene::getInstance('testLucene'); 
     
    3737  public function getFieldValue($field) 
    3838  { 
    39     if (!isset($this->$field)) throw new Exception('You said to'); 
     39    if (!isset($this->$field)) throw new Exception('Field ' . $field . ' does not exist'); 
    4040 
    4141    return $this->$field; 
     
    8181$t->is($result->getSequence(), '123', '->getXXX() returns property XXX on document'); 
    8282$t->ok($result->hasSequence(), '->hasXXX() returns true if document has property XXX'); 
     83 
     84$doc->super_duper_man = 'Fabien Potencier'; 
     85$t->is($result->getSuperDuperMan(), 'Fabien Potencier', '->getXXX() returns property XXX for camel case'); 
     86$t->ok($result->hasSuperDuperMan(), '->hasXXX() returns if document has property XXX for camel case'); 
    8387 
    8488try {