Author: rande
Date: 2010-05-10 23:26:53 +0200 (Mon, 10 May 2010)
New Revision: 29406
Modified:
plugins/sfSolrPlugin/branches/sf1.2/lib/indexer/sfLuceneDoctrineIndexer.class.php
plugins/sfSolrPlugin/branches/sf1.2/lib/indexer/sfLuceneDoctrineIndexerHandler.class.php
plugins/sfSolrPlugin/branches/sf1.2/lib/indexer/sfLuceneModelIndexer.class.php
Log:
[sfSolrPlugin] restore sfl_title and sfl_description field
Modified:
plugins/sfSolrPlugin/branches/sf1.2/lib/indexer/sfLuceneDoctrineIndexer.class.php
===================================================================
---
plugins/sfSolrPlugin/branches/sf1.2/lib/indexer/sfLuceneDoctrineIndexer.class.php
2010-05-10 21:19:03 UTC (rev 29405)
+++
plugins/sfSolrPlugin/branches/sf1.2/lib/indexer/sfLuceneDoctrineIndexer.class.php
2010-05-10 21:26:53 UTC (rev 29406)
@@ -26,9 +26,10 @@
{
$this->getSearch()->getEventDispatcher()->notify(new sfEvent($this,
'indexer.log', array('model "%s" cancelled indexation - primary key = %s',
$this->getModelName(), current($this->getModel()->identifier()))));
+
return false;
}
-
+
$old_culture = null;
// automatic symfony i18n detection
@@ -43,7 +44,6 @@
$doc = $this->configureDocumentFields($doc);
//$doc = $this->configureDocumentCategories($doc);
$doc = $this->configureDocumentMetas($doc);
-
// add document
$doc->setField('sfl_guid', $this->getModelGuid());
Modified:
plugins/sfSolrPlugin/branches/sf1.2/lib/indexer/sfLuceneDoctrineIndexerHandler.class.php
===================================================================
---
plugins/sfSolrPlugin/branches/sf1.2/lib/indexer/sfLuceneDoctrineIndexerHandler.class.php
2010-05-10 21:19:03 UTC (rev 29405)
+++
plugins/sfSolrPlugin/branches/sf1.2/lib/indexer/sfLuceneDoctrineIndexerHandler.class.php
2010-05-10 21:26:53 UTC (rev 29406)
@@ -91,7 +91,9 @@
{
$start1 = microtime(true);
- $doc = $this->getFactory()->getModel($record)->getDocument();
+ $indexer = $this->getFactory()->getModel($record);
+
+ $doc = $indexer->getDocument();
// $this->getSearch()->getEventDispatcher()->notify(new
sfEvent($this,'indexer.log', array(' - creating one object in %s seconds.',
number_format(microtime(true) - $start1, 5))));
if(!$doc)
Modified:
plugins/sfSolrPlugin/branches/sf1.2/lib/indexer/sfLuceneModelIndexer.class.php
===================================================================
---
plugins/sfSolrPlugin/branches/sf1.2/lib/indexer/sfLuceneModelIndexer.class.php
2010-05-10 21:19:03 UTC (rev 29405)
+++
plugins/sfSolrPlugin/branches/sf1.2/lib/indexer/sfLuceneModelIndexer.class.php
2010-05-10 21:26:53 UTC (rev 29406)
@@ -21,7 +21,7 @@
static
$model_properties = array();
- private
+ protected
$instance,
$model_name; // model name used in the search.yml file
@@ -35,6 +35,11 @@
$models = $search->getParameter('models')->getAll();
$this->model_name = false;
+ if(!is_object($instance))
+ {
+ throw new sfLuceneIndexerException('The instance is not an object');
+ }
+
// fix class inheritance
foreach(array_keys($models) as $model)
{
@@ -69,7 +74,7 @@
/**
* Returns the instance of the model
*/
- protected function getModel()
+ public function getModel()
{
return $this->instance;
}
@@ -123,9 +128,30 @@
*/
protected function configureDocumentMetas(sfLuceneDocument $doc)
{
- $doc->setField('sfl_model', $this->getModelName());
- $doc->setField('sfl_type', 'model');
-
+
+ $properties = $this->getModelProperties();
+
+ $doc->setField('sfl_model', $this->getModelName());
+ $doc->setField('sfl_type', 'model');
+
+ try
+ {
+ $doc->setField('sfl_title',
$this->getModel()->get($properties->get('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()))));
+ }
+
+ try
+ {
+ $doc->setField('sfl_description',
$this->getModel()->get($properties->get('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()))));
+ }
+
return $doc;
}
--
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.