Created
November 14, 2014 10:15
-
-
Save dfritschy/62be9df4d53f160c02ac to your computer and use it in GitHub Desktop.
Full Text Search in eZ Publish 5 using a legacy closure
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$searchText = $request->query->get('SearchText'); | |
$sort = array( 'modified' => 'false' ); | |
$contentTypeIdenfiers = array( 31 ); | |
$searchResult = $this->getLegacyKernel()->runCallback( | |
function () use ( $searchText, $sort, $contentTypeIdenfiers ) | |
{ | |
// eZFunctionHandler::execute is the equivalent for a legacy template fetch function | |
// The following is the same than fetch( 'content', 'search', hash(...) ) | |
return eZFunctionHandler::execute( | |
'content', | |
'search', | |
array( | |
'text' => $searchText, | |
'sort_by' => $sort, | |
'class_id' => $contentTypeIdenfiers | |
) | |
); | |
} | |
); | |
$resultList = array(); | |
if ( $searchResult ) { | |
foreach ( $searchResult['SearchResult'] as $hit ) | |
{ | |
$resultList[] = $this->getRepository()->getContentService()->loadContent( $hit->ContentObjectID ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment