-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extracted redundant TextLine and ISBN SearchField into a common base (#…
- Loading branch information
Showing
3 changed files
with
62 additions
and
110 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,56 @@ | ||
<?php | ||
|
||
/** | ||
* @copyright Copyright (C) Ibexa AS. All rights reserved. | ||
* @license For full copyright and license information view LICENSE file distributed with this source code. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Ibexa\Core\FieldType; | ||
|
||
use Ibexa\Contracts\Core\FieldType\Indexable; | ||
use Ibexa\Contracts\Core\Persistence\Content\Field; | ||
use Ibexa\Contracts\Core\Persistence\Content\Type\FieldDefinition; | ||
use Ibexa\Contracts\Core\Search; | ||
|
||
abstract class BaseSingleTextLineSearchField implements Indexable | ||
{ | ||
/** | ||
* @return \Ibexa\Contracts\Core\Search\Field[] | ||
*/ | ||
public function getIndexData(Field $field, FieldDefinition $fieldDefinition): array | ||
{ | ||
return [ | ||
new Search\Field( | ||
'value', | ||
$field->value->data, | ||
new Search\FieldType\StringField() | ||
), | ||
new Search\Field( | ||
'fulltext', | ||
$field->value->data, | ||
new Search\FieldType\FullTextField() | ||
), | ||
]; | ||
} | ||
|
||
/** | ||
* @return array<string, \Ibexa\Contracts\Core\Search\FieldType> | ||
*/ | ||
public function getIndexDefinition(): array | ||
{ | ||
return [ | ||
'value' => new Search\FieldType\StringField(), | ||
]; | ||
} | ||
|
||
public function getDefaultMatchField(): string | ||
{ | ||
return 'value'; | ||
} | ||
|
||
public function getDefaultSortField(): string | ||
{ | ||
return $this->getDefaultMatchField(); | ||
} | ||
} |
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