diff --git a/eZ/Publish/LegacySearch/LegacySearchFactory.php b/eZ/Publish/LegacySearch/LegacySearchFactory.php index 1f6b01e..ada6bd7 100644 --- a/eZ/Publish/LegacySearch/LegacySearchFactory.php +++ b/eZ/Publish/LegacySearch/LegacySearchFactory.php @@ -8,17 +8,22 @@ namespace EzSystems\RecommendationBundle\eZ\Publish\LegacySearch; -/** - * @TODO fixme - */ +use EzSystems\RecommendationBundle\eZ\Publish\LegacySearch; + class LegacySearchFactory { public static function build(\Closure $legacyKernelClosure) { - return $legacyKernelClosure()->runCallback( - function () { - return \eZSearch::getEngine(); - } - ); + try { + $searchEngine = $legacyKernelClosure()->runCallback( + function () { + return \eZSearch::getEngine(); + } + ); + } catch (\Exception $e) { + $searchEngine = new NullSearchEngine(); + } + + return $searchEngine; } } diff --git a/eZ/Publish/LegacySearch/NullSearchEngine.php b/eZ/Publish/LegacySearch/NullSearchEngine.php new file mode 100644 index 0000000..38f7027 --- /dev/null +++ b/eZ/Publish/LegacySearch/NullSearchEngine.php @@ -0,0 +1,62 @@ +legacySearchEngine->addNodeAssignment( $mainNodeID, $objectID, $nodeAssignmentIDList, $isMoved ); } } - - public static function buildLegacySearchEngine($legacyKernelClosure) - { - return $legacyKernelClosure()->runCallback( - function () { - return \eZSearch::getEngine(); - } - ); - } }