Author: rande
Date: 2010-05-17 23:30:05 +0200 (Mon, 17 May 2010)
New Revision: 29497

Modified:
   
plugins/sfSolrPlugin/branches/sf1.2/lib/indexer/sfLuceneModelIndexer.class.php
   plugins/sfSolrPlugin/branches/sf1.2/lib/results/sfLuceneModelResult.class.php
Log:
[sfSolrPlugin] fix meta description field accessor (thanks to Lukas Kahwe Smith)

Modified: 
plugins/sfSolrPlugin/branches/sf1.2/lib/indexer/sfLuceneModelIndexer.class.php
===================================================================
--- 
plugins/sfSolrPlugin/branches/sf1.2/lib/indexer/sfLuceneModelIndexer.class.php  
    2010-05-17 16:00:12 UTC (rev 29496)
+++ 
plugins/sfSolrPlugin/branches/sf1.2/lib/indexer/sfLuceneModelIndexer.class.php  
    2010-05-17 21:30:05 UTC (rev 29497)
@@ -130,26 +130,41 @@
   {
     
     $properties = $this->getModelProperties();
+    $fields = $properties->get('fields');
     
     $doc->setField('sfl_model',       $this->getModelName());
     $doc->setField('sfl_type',        'model');
     
     try
     {
-      $doc->setField('sfl_title', 
$this->getModel()->get($properties->get('title')));
+      if ($properties->get('title')) {
+        $title = $fields->get($properties->get('title'));
+        $title = (isset($title) && $title->get('alias'))
+          ? $this->getModel()->{$title->get('alias')}()
+          : $this->getModel()->get($properties->get('title'));
+
+        $doc->setField('sfl_title', $title);
     }
+    }
     catch(Doctrine_Record_Exception $e)
     {
-      $this->getSearch()->getEventDispatcher()->notify(new sfEvent($this, 
'indexer.log', array('model "%s" does not have a valid `sfl_title` field - 
primary key = %s', $this->getModelName(), 
current($this->getModel()->identifier()))));
+      $this->getSearch()->getEventDispatcher()->notify(new sfEvent($this, 
'indexer.log', array('model "%s" does not have a valid `sfl_title` field - 
primary key = %s: %s', $this->getModelName(), $properties->get('title'), 
current($this->getModel()->identifier()), $e->getMessage())));
     }
     
     try
     {
-      $doc->setField('sfl_description', 
$this->getModel()->get($properties->get('description')));
+      if ($properties->get('description')) {
+        $description = $fields->get($properties->get('description'));
+        $description = (isset($description) && $description->get('alias'))
+          ? $this->getModel()->{$description->get('alias')}()
+          : $this->getModel()->get($properties->get('description'));
+
+        $doc->setField('sfl_description', $description);
     }
+    }
     catch(Doctrine_Record_Exception $e)
     {
-      $this->getSearch()->getEventDispatcher()->notify(new sfEvent($this, 
'indexer.log', array('model "%s" does not have a valid `sfl_description` field 
- primary key = %s', $this->getModelName(), 
current($this->getModel()->identifier()))));    
+        $this->getSearch()->getEventDispatcher()->notify(new sfEvent($this, 
'indexer.log', array('model "%s" does not have a valid `sfl_description` field 
using "%s" - primary key = %s: %s', $this->getModelName(), 
$properties->get('description'), current($this->getModel()->identifier()), 
$e->getMessage())));
     }
     
     return $doc;

Modified: 
plugins/sfSolrPlugin/branches/sf1.2/lib/results/sfLuceneModelResult.class.php
===================================================================
--- 
plugins/sfSolrPlugin/branches/sf1.2/lib/results/sfLuceneModelResult.class.php   
    2010-05-17 16:00:12 UTC (rev 29496)
+++ 
plugins/sfSolrPlugin/branches/sf1.2/lib/results/sfLuceneModelResult.class.php   
    2010-05-17 21:30:05 UTC (rev 29497)
@@ -22,6 +22,10 @@
   */
   public function getInternalTitle()
   {
+    if ($this->result->__isset('sfl_title')) {
+        return $this->result->__get('sfl_title');
+    }
+
     $model = $this->retrieveModel();
 
     if ($model->has('title') && !is_null($model->get('title')))
@@ -89,6 +93,10 @@
 
   public function getInternalDescription()
   {
+    if ($this->result->__isset('sfl_description')) {
+        return $this->result->__get('sfl_description');
+    }
+
     $model = $this->retrieveModel();
 
     if ($model->has('description') && !is_null($model->get('description')))
@@ -112,8 +120,7 @@
   */
   protected function retrieveModel()
   {
-
     return $this->search->getParameter('models')->get($this->getSflModel());
   }
   
-}
\ No newline at end of file
+}

-- 
You received this message because you are subscribed to the Google Groups 
"symfony SVN" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/symfony-svn?hl=en.

Reply via email to