Skip to content
Permalink
Browse files

Merge pull request #1233 from ezsystems/impl-EZP-24272-indexable-time

Implement EZP-24272: Indexable Time field type
  • Loading branch information...
pspanja committed May 5, 2015
2 parents 27f4aae + f06c0e0 commit 394b73baaaa96d0adf8bce75cf26edf9146f44bb
@@ -19,7 +19,7 @@
* @group integration
* @group field-type
*/
class TimeIntegrationTest extends BaseIntegrationTest
class TimeIntegrationTest extends SearchBaseIntegrationTest
{
/**
* Get name of tested field type
@@ -341,4 +341,24 @@ public function providerForTestIsNotEmptyValue()
),
);
}
protected function getValidSearchValueOne()
{
return new TimeValue( $this->getSearchTargetValueOne() );
}
protected function getValidSearchValueTwo()
{
return new TimeValue( $this->getSearchTargetValueTwo() );
}
protected function getSearchTargetValueOne()
{
return 9600;
}
protected function getSearchTargetValueTwo()
{
return 14400;
}
}
@@ -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\Time;
use eZ\Publish\SPI\Persistence\Content\Field;
use eZ\Publish\SPI\FieldType\Indexable;
use eZ\Publish\SPI\Search;
/**
* Indexable definition for Time 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,
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";
}
}
@@ -14,6 +14,7 @@ parameters:
ezpublish.fieldType.indexable.ezcountry.class: eZ\Publish\Core\FieldType\Country\SearchField
ezpublish.fieldType.indexable.ezinteger.class: eZ\Publish\Core\FieldType\Integer\SearchField
ezpublish.fieldType.indexable.ezfloat.class: eZ\Publish\Core\FieldType\Float\SearchField
ezpublish.fieldType.indexable.eztime.class: eZ\Publish\Core\FieldType\Time\SearchField
ezpublish.fieldType.indexable.unindexed.class: eZ\Publish\Core\FieldType\Unindexed

services:
@@ -67,6 +68,11 @@ services:
tags:
- {name: ezpublish.fieldType.indexable, alias: ezbinaryfile}

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

ezpublish.fieldType.indexable.eztext:
class: %ezpublish.fieldType.indexable.eztext.class%
tags:
@@ -110,7 +116,6 @@ services:
- {name: ezpublish.fieldType.indexable, alias: ezuser}
- {name: ezpublish.fieldType.indexable, alias: ezkeyword}
- {name: ezpublish.fieldType.indexable, alias: ezdate}
- {name: ezpublish.fieldType.indexable, alias: eztime}
- {name: ezpublish.fieldType.indexable, alias: ezinisetting}
- {name: ezpublish.fieldType.indexable, alias: ezpackage}
- {name: ezpublish.fieldType.indexable, alias: ezurl}

0 comments on commit 394b73b

Please sign in to comment.
You can’t perform that action at this time.