forked from Novactive/NovaeZSolrSearchExtraBundle
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Florian ALEXANDRE
committed
Dec 11, 2018
1 parent
9cedae2
commit d636241
Showing
4 changed files
with
133 additions
and
0 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
/** | ||
* NovaeZSolrSearchExtraBundle. | ||
* | ||
* @package NovaeZSolrSearchExtraBundle | ||
* | ||
* @author Novactive <f.alexandre@novactive.com> | ||
* @copyright 2018 Novactive | ||
* @license https://github.com/Novactive/NovaeZSolrSearchExtraBundle/blob/master/LICENSE | ||
*/ | ||
|
||
namespace Novactive\EzSolrSearchExtra\Query\SortClause; | ||
|
||
use eZ\Publish\API\Repository\Values\Content\Query\SortClause; | ||
|
||
/** | ||
* Class Score. | ||
*/ | ||
class Score extends SortClause | ||
{ | ||
/** | ||
* Constructs a new Score SortClause. | ||
* | ||
* @param string $sortDirection | ||
*/ | ||
public function __construct($sortDirection = Query::SORT_ASC) | ||
{ | ||
parent::__construct('score', $sortDirection); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
/** | ||
* NovaeZSolrSearchExtraBundle. | ||
* | ||
* @package NovaeZSolrSearchExtraBundle | ||
* | ||
* @author Novactive <f.alexandre@novactive.com> | ||
* @copyright 2018 Novactive | ||
* @license https://github.com/Novactive/NovaeZSolrSearchExtraBundle/blob/master/LICENSE | ||
*/ | ||
|
||
namespace Novactive\EzSolrSearchExtra\Query\SortClauseHandler; | ||
|
||
use eZ\Publish\API\Repository\Values\Content\Query\SortClause as APISortClause; | ||
use eZ\Publish\Core\Persistence\Database\SelectQuery; | ||
use eZ\Publish\Core\Search\Legacy\Content\Common\Gateway\SortClauseHandler; | ||
use Novactive\EzSolrSearchExtra\Query\SortClause; | ||
|
||
/** | ||
* Class Score. | ||
*/ | ||
class Score extends SortClauseHandler | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function accept(APISortClause $sortClause) | ||
{ | ||
return $sortClause instanceof SortClause\Score; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function applySelect(SelectQuery $query, APISortClause $sortClause, $number) | ||
{ | ||
return null; | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
/** | ||
* NovaeZSolrSearchExtraBundle. | ||
* | ||
* @package NovaeZSolrSearchExtraBundle | ||
* | ||
* @author Novactive <f.alexandre@novactive.com> | ||
* @copyright 2018 Novactive | ||
* @license https://github.com/Novactive/NovaeZSolrSearchExtraBundle/blob/master/LICENSE | ||
*/ | ||
|
||
namespace Novactive\EzSolrSearchExtra\Query\SortClauseVisitor; | ||
|
||
use eZ\Publish\API\Repository\Values\Content\Query\SortClause as APISortClause; | ||
use EzSystems\EzPlatformSolrSearchEngine\Query\SortClauseVisitor; | ||
use Novactive\EzSolrSearchExtra\Query\SortClause; | ||
|
||
/** | ||
* Class Score. | ||
*/ | ||
class Score extends SortClauseVisitor | ||
{ | ||
/** | ||
* Check if visitor is applicable to current sortClause. | ||
* | ||
* @param APISortClause $sortClause | ||
* | ||
* @return bool | ||
*/ | ||
public function canVisit(APISortClause $sortClause) | ||
{ | ||
return $sortClause instanceof SortClause\Score; | ||
} | ||
|
||
/** | ||
* Map field value to a proper Solr representation. | ||
* | ||
* @param APISortClause $sortClause | ||
* | ||
* @return string | ||
*/ | ||
public function visit(APISortClause $sortClause) | ||
{ | ||
return 'score' . $this->getDirection($sortClause); | ||
} | ||
} |