Skip to content

Instantly share code, notes, and snippets.

@dfritschy
Created November 14, 2014 10:15
Show Gist options
  • Save dfritschy/62be9df4d53f160c02ac to your computer and use it in GitHub Desktop.
Save dfritschy/62be9df4d53f160c02ac to your computer and use it in GitHub Desktop.
Full Text Search in eZ Publish 5 using a legacy closure
$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