public function getDocument()
{
if (!$this->shouldIndex()) {
$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
if ($this->getModel()->getTable()->hasRelation('Translation')) {
$old_culture = sfDoctrineRecord::getDefaultCulture();
sfDoctrineRecord::setDefaultCulture($this->getSearch()->getParameter('culture'));
}
// build document
$doc = $this->getBaseDocument();
$doc = $this->configureDocumentFields($doc);
//$doc = $this->configureDocumentCategories($doc);
$doc = $this->configureDocumentMetas($doc);
// add document
$doc->setField('sfl_guid', $this->getModelGuid());
// restore culture in symfony i18n detection
if ($old_culture) {
sfDoctrineRecord::setDefaultCulture($old_culture);
}
return $doc;
}