refactor content loop splitting parseResults method

This commit is contained in:
Manuel Raynaud
2014-04-30 10:57:04 +02:00
parent 0b36b2222d
commit 67293555ba

View File

@@ -205,7 +205,7 @@ class Content extends BaseI18nLoop implements PropelSearchLoopInterface
/** @var \Thelia\Model\Content $content */ /** @var \Thelia\Model\Content $content */
foreach ($loopResult->getResultDataCollection() as $content) { foreach ($loopResult->getResultDataCollection() as $content) {
$loopResultRow = new LoopResultRow($content); $loopResultRow = new LoopResultRow($content);
$defaultFolderId = $content->getDefaultFolderId();
$loopResultRow->set("ID" , $content->getId()) $loopResultRow->set("ID" , $content->getId())
->set("IS_TRANSLATED" , $content->getVirtualColumn('IS_TRANSLATED')) ->set("IS_TRANSLATED" , $content->getVirtualColumn('IS_TRANSLATED'))
->set("LOCALE" , $this->locale) ->set("LOCALE" , $this->locale)
@@ -218,14 +218,31 @@ class Content extends BaseI18nLoop implements PropelSearchLoopInterface
->set("META_DESCRIPTION" , $content->getVirtualColumn('i18n_META_DESCRIPTION')) ->set("META_DESCRIPTION" , $content->getVirtualColumn('i18n_META_DESCRIPTION'))
->set("META_KEYWORDS" , $content->getVirtualColumn('i18n_META_KEYWORDS')) ->set("META_KEYWORDS" , $content->getVirtualColumn('i18n_META_KEYWORDS'))
->set("POSITION" , $content->getPosition()) ->set("POSITION" , $content->getPosition())
->set("DEFAULT_FOLDER" , $content->getDefaultFolderId()) ->set("DEFAULT_FOLDER" , $defaultFolderId)
->set("VISIBLE" , $content->getVisible()) ->set("VISIBLE" , $content->getVisible())
; ;
$loopResult->addRow($this->findNextPrev($loopResultRow, $content, $defaultFolderId));
}
return $loopResult;
}
/**
* @param LoopResultRow $loopResultRow
* @param \Thelia\Model\Content $content
* @param $defaultFolderId
* @return LoopResultRow
*/
private function findNextPrev(LoopResultRow $loopResultRow, \Thelia\Model\Content $content, $defaultFolderId)
{
if ($this->getBackend_context() || $this->getWithPrevNextInfo()) { if ($this->getBackend_context() || $this->getWithPrevNextInfo()) {
$defaultFolderId = $content->getDefaultFolderId();
// Find previous and next category // Find previous and next category
$previous = ContentQuery::create() $previous = ContentQuery::create()
->joinContentFolder() ->joinContentFolder()
@@ -251,11 +268,7 @@ class Content extends BaseI18nLoop implements PropelSearchLoopInterface
; ;
} }
$loopResult->addRow($loopResultRow); return $loopResultRow;
}
return $loopResult;
} }
} }