Skip to content

Commit

Permalink
Merge pull request #1246 from ezsystems/impl-24319-indexable-isbn
Browse files Browse the repository at this point in the history
Implement EZP-24319: Indexable ISBN field type
  • Loading branch information
pspanja committed May 4, 2015
2 parents c8493b5 + e3337a7 commit 27f4aae
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 3 deletions.
Expand Up @@ -18,7 +18,7 @@
* @group integration
* @group field-type
*/
class ISBNIntegrationTest extends BaseIntegrationTest
class ISBNIntegrationTest extends SearchBaseIntegrationTest
{
/**
* Get name of tested field type
Expand Down Expand Up @@ -343,4 +343,14 @@ public function providerForTestIsNotEmptyValue()
),
);
}

protected function getValidSearchValueOne()
{
return "9780099067504";
}

protected function getValidSearchValueTwo()
{
return "9780380448340";
}
}
65 changes: 65 additions & 0 deletions eZ/Publish/Core/FieldType/ISBN/SearchField.php
@@ -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\ISBN;

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

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

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

/**
* 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";
}
}
4 changes: 2 additions & 2 deletions eZ/Publish/Core/settings/indexable_fieldtypes.yml
@@ -1,6 +1,7 @@
parameters:
ezpublish.fieldType.indexable.ezstring.class: eZ\Publish\Core\FieldType\TextLine\SearchField
ezpublish.fieldType.indexable.eztext.class: eZ\Publish\Core\FieldType\TextBlock\SearchField
ezpublish.fieldType.indexable.ezisbn.class: eZ\Publish\Core\FieldType\ISBN\SearchField
ezpublish.fieldType.indexable.ezboolean.class: eZ\Publish\Core\FieldType\Checkbox\SearchField
ezpublish.fieldType.indexable.ezdatetime.class: eZ\Publish\Core\FieldType\DateAndTime\SearchField
ezpublish.fieldType.indexable.ezemail.class: eZ\Publish\Core\FieldType\EmailAddress\SearchField
Expand Down Expand Up @@ -93,9 +94,8 @@ services:
tags:
- {name: ezpublish.fieldType.indexable, alias: ezrichtext}

# TODO: define proper type
ezpublish.fieldType.indexable.ezisbn:
class: %ezpublish.fieldType.indexable.ezstring.class%
class: %ezpublish.fieldType.indexable.ezisbn.class%
tags:
- {name: ezpublish.fieldType.indexable, alias: ezisbn}

Expand Down

0 comments on commit 27f4aae

Please sign in to comment.