forked from ezsystems/ezpublish-kernel
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request ezsystems#1231 from ezsystems/impl-EZP-24271-index…
…able-dateandtime Implement EZP-24271: Indexable DateAndTime field type
- Loading branch information
Showing
4 changed files
with
117 additions
and
2 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,65 @@ | ||
<?php | ||
/** | ||
* This file is part of the eZ Publish Kernel package | ||
* | ||
* @copyright Copyright (C) eZ Systems AS. All rights reserved. | ||
* @license For full copyright and license information view LICENSE file distributed with this source code. | ||
* @version //autogentag// | ||
*/ | ||
|
||
namespace eZ\Publish\Core\FieldType\DateAndTime; | ||
|
||
use eZ\Publish\SPI\Persistence\Content\Field; | ||
use eZ\Publish\SPI\FieldType\Indexable; | ||
use eZ\Publish\SPI\Search; | ||
|
||
/** | ||
* Indexable definition for DateAndTime field type | ||
*/ | ||
class SearchField implements Indexable | ||
{ | ||
/** | ||
* Get index data for field for search backend | ||
* | ||
* @param Field $field | ||
* | ||
* @return \eZ\Publish\SPI\Search\Field[] | ||
*/ | ||
public function getIndexData( Field $field ) | ||
{ | ||
return array( | ||
new Search\Field( | ||
'value', | ||
$field->value->data['timestamp'], | ||
new Search\FieldType\DateField() | ||
), | ||
); | ||
} | ||
|
||
/** | ||
* Get index field types for search backend | ||
* | ||
* @return \eZ\Publish\SPI\Search\FieldType[] | ||
*/ | ||
public function getIndexDefinition() | ||
{ | ||
return array( | ||
'value' => new Search\FieldType\DateField(), | ||
); | ||
} | ||
|
||
/** | ||
* Get name of the default field to be used for query and sort. | ||
* | ||
* As field types can index multiple fields (see MapLocation field type's | ||
* implementation of this interface), this method is used to define default | ||
* field for query and sort. Default field is typically used by Field | ||
* criterion and sort clause. | ||
* | ||
* @return string | ||
*/ | ||
public function getDefaultField() | ||
{ | ||
return "value"; | ||
} | ||
} |
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