Skip to content

Commit

Permalink
EZP-24270: implemented Indexable definition for Date field type
Browse files Browse the repository at this point in the history
  • Loading branch information
pspanja committed Apr 17, 2015
1 parent bf76f53 commit bd17e3d
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 1 deletion.
65 changes: 65 additions & 0 deletions eZ/Publish/Core/FieldType/Date/SearchField.php
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\Date;

use eZ\Publish\SPI\Persistence\Content\Field;
use eZ\Publish\SPI\FieldType\Indexable;
use eZ\Publish\SPI\Search;

/**
* Indexable definition for Date 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\IntegerField()
),
);
}

/**
* Get index field types for search backend
*
* @return \eZ\Publish\SPI\Search\FieldType[]
*/
public function getIndexDefinition()
{
return array(
'value' => new Search\FieldType\IntegerField(),
);
}

/**
* 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";
}
}
7 changes: 6 additions & 1 deletion eZ/Publish/Core/settings/indexable_fieldtypes.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
parameters:
ezpublish.fieldType.indexable.ezstring.class: eZ\Publish\Core\FieldType\TextLine\SearchField
ezpublish.fieldType.indexable.ezdate.class: eZ\Publish\Core\FieldType\Date\SearchField
ezpublish.fieldType.indexable.ezprice.class: eZ\Publish\Core\FieldType\Price\SearchField
ezpublish.fieldType.indexable.ezgmaplocation.class: eZ\Publish\Core\FieldType\MapLocation\SearchField
ezpublish.fieldType.indexable.ezcountry.class: eZ\Publish\Core\FieldType\Country\SearchField
Expand Down Expand Up @@ -27,6 +28,11 @@ services:
tags:
- {name: ezpublish.fieldType.indexable, alias: ezcountry}

ezpublish.fieldType.indexable.ezdate:
class: %ezpublish.fieldType.indexable.ezdate.class%
tags:
- {name: ezpublish.fieldType.indexable, alias: ezdate}

ezpublish.fieldType.indexable.ezinteger:
class: %ezpublish.fieldType.indexable.ezinteger.class%
tags:
Expand Down Expand Up @@ -64,7 +70,6 @@ services:
- {name: ezpublish.fieldType.indexable, alias: ezimage}
- {name: ezpublish.fieldType.indexable, alias: ezboolean}
- {name: ezpublish.fieldType.indexable, alias: ezkeyword}
- {name: ezpublish.fieldType.indexable, alias: ezdate}
- {name: ezpublish.fieldType.indexable, alias: eztime}
- {name: ezpublish.fieldType.indexable, alias: ezdatetime}
- {name: ezpublish.fieldType.indexable, alias: ezinisetting}
Expand Down

0 comments on commit bd17e3d

Please sign in to comment.