Skip to content

Commit

Permalink
EZP-23860: RecommendationBundle breaks left tree menu
Browse files Browse the repository at this point in the history
  • Loading branch information
Rafał Toborek committed Jun 11, 2015
1 parent 566cbc2 commit 93709d6
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 17 deletions.
21 changes: 13 additions & 8 deletions eZ/Publish/LegacySearch/LegacySearchFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
62 changes: 62 additions & 0 deletions eZ/Publish/LegacySearch/NullSearchEngine.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?php
/**
* This file is part of the EzSystemsRecommendationBundle package
*
* @copyright Copyright (C) eZ Systems AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributd with this source code.
*/

namespace EzSystems\RecommendationBundle\eZ\Publish\LegacySearch;

use ezpSearchEngine;

/**
* Recommendation legacy search engine mockup.
*
* This class was created to imitate working of `ezpSearchEngine` which is
* responsible for breaking left tree menu in eZ Publish administration panel.
*
* @link https://jira.ez.no/browse/EZP-23860
*/
class NullSearchEngine implements ezpSearchEngine
{
public function needCommit()
{
return false;
}

public function needRemoveWithUpdate()
{
return false;
}

public function addObject( $contentObject, $commit = true )
{
return false;
}

public function removeObject( $contentObject, $commit = null )
{
return false;
}

public function removeObjectById( $contentObjectId, $commit = null )
{
return false;
}

public function search( $searchText, $params = array(), $searchTypes = array() )
{
return array();
}

public function supportedSearchTypes()
{
return array();
}

public function commit()
{

}
}
9 changes: 0 additions & 9 deletions eZ/Publish/LegacySearch/RecommendationLegacySearchEngine.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,4 @@ public function addNodeAssignment( $mainNodeID, $objectID, $nodeAssignmentIDList
$this->legacySearchEngine->addNodeAssignment( $mainNodeID, $objectID, $nodeAssignmentIDList, $isMoved );
}
}

public static function buildLegacySearchEngine($legacyKernelClosure)
{
return $legacyKernelClosure()->runCallback(
function () {
return \eZSearch::getEngine();
}
);
}
}

0 comments on commit 93709d6

Please sign in to comment.