-
Notifications
You must be signed in to change notification settings - Fork 206
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 #1229 from ezsystems/impl-EZP-24269-indexable-text…
…block Implement EZP-24269: Indexable TextBlock field type
- Loading branch information
Showing
10 changed files
with
153 additions
and
10 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
39 changes: 39 additions & 0 deletions
39
eZ/Publish/API/Repository/Tests/FieldType/SearchableTextBlock.php
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,39 @@ | ||
<?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\API\Repository\Tests\FieldType; | ||
|
||
use eZ\Publish\Core\FieldType\TextBlock\Type; | ||
use eZ\Publish\Core\Base\Exceptions\InvalidArgumentType; | ||
|
||
/** | ||
* TextBlock field type is not searchable in Legacy search engine, but will | ||
* be searchable with Solr and Elasticsearch search engines. | ||
* | ||
* This is implementation simply extends the original implementation in order to | ||
* define the field type as searchable, so that it can be tested. | ||
*/ | ||
class SearchableTextBlock extends Type | ||
{ | ||
public function isSearchable() | ||
{ | ||
return true; | ||
} | ||
|
||
static protected function checkValueType( $value ) | ||
{ | ||
$fieldTypeFQN = "eZ\\Publish\\Core\\FieldType\\TextBlock\\Value"; | ||
$valueFQN = substr_replace( $fieldTypeFQN, "Value", strrpos( $fieldTypeFQN, "\\" ) + 1 ); | ||
|
||
if ( !$value instanceof $valueFQN ) | ||
{ | ||
throw new InvalidArgumentType( "\$value", $valueFQN, $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
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\TextBlock; | ||
|
||
use eZ\Publish\SPI\Persistence\Content\Field; | ||
use eZ\Publish\SPI\FieldType\Indexable; | ||
use eZ\Publish\SPI\Search; | ||
|
||
/** | ||
* Indexable definition for TextBlock 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\MultipleStringField() | ||
), | ||
); | ||
} | ||
|
||
/** | ||
* Get index field types for search backend | ||
* | ||
* @return \eZ\Publish\SPI\Search\FieldType[] | ||
*/ | ||
public function getIndexDefinition() | ||
{ | ||
return array( | ||
'value' => new Search\FieldType\MultipleStringField(), | ||
); | ||
} | ||
|
||
/** | ||
* 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
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
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