-
Notifications
You must be signed in to change notification settings - Fork 4
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
1 parent
2dcc112
commit 622139f
Showing
3 changed files
with
63 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
namespace Netgen\EzPlatformSearchExtra\API\Values\Content\Query\SortClause; | ||
|
||
use eZ\Publish\API\Repository\Values\Content\Query; | ||
use eZ\Publish\API\Repository\Values\Content\Query\SortClause; | ||
use Netgen\EzPlatformSearchExtra\API\Values\Content\Query\Criterion\SubdocumentQuery; | ||
use Netgen\EzPlatformSearchExtra\API\Values\Content\Query\SortClause\Target\SubdocumentTarget; | ||
|
||
/** | ||
* CustomField sort clause is used to sort Content by custom field indexed for this content. | ||
*/ | ||
final class CustomField extends SortClause | ||
{ | ||
/** | ||
* @param string $fieldName | ||
* @param string $sortDirection | ||
*/ | ||
public function __construct($fieldName, $sortDirection = Query::SORT_ASC) | ||
{ | ||
parent::__construct($fieldName, $sortDirection); | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
lib/Core/Search/Solr/Query/Common/SortClauseVisitor/CustomField.php
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,34 @@ | ||
<?php | ||
|
||
namespace Netgen\EzPlatformSearchExtra\Core\Search\Solr\Query\Common\SortClauseVisitor; | ||
|
||
use EzSystems\EzPlatformSolrSearchEngine\Query\SortClauseVisitor; | ||
use eZ\Publish\API\Repository\Values\Content\Query\SortClause; | ||
use \Netgen\EzPlatformSearchExtra\API\Values\Content\Query\SortClause\CustomField as CustomFieldSortClause; | ||
|
||
class CustomField extends SortClauseVisitor | ||
{ | ||
/** | ||
* Check if visitor is applicable to current sortClause. | ||
* | ||
* @param SortClause $sortClause | ||
* | ||
* @return bool | ||
*/ | ||
public function canVisit(SortClause $sortClause) | ||
{ | ||
return $sortClause instanceof CustomFieldSortClause; | ||
} | ||
|
||
/** | ||
* Map field value to a proper Solr representation. | ||
* | ||
* @param SortClause $sortClause | ||
* | ||
* @return string | ||
*/ | ||
public function visit(SortClause $sortClause) | ||
{ | ||
return $sortClause->target . $this->getDirection($sortClause); | ||
} | ||
} |
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