-
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 #1245 from ezsystems/impl-EZP-24314-indexable-bina…
…ryfile Implement EZP-24314: Indexable BinaryFile field type
- Loading branch information
Showing
4 changed files
with
323 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
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,77 @@ | ||
<?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\BinaryFile; | ||
|
||
use eZ\Publish\SPI\Persistence\Content\Field; | ||
use eZ\Publish\SPI\FieldType\Indexable; | ||
use eZ\Publish\SPI\Search; | ||
|
||
/** | ||
* Indexable definition for BinaryFile 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( | ||
'file_name', | ||
$field->value->externalData["fileName"], | ||
new Search\FieldType\StringField() | ||
), | ||
new Search\Field( | ||
'file_size', | ||
$field->value->externalData["fileSize"], | ||
new Search\FieldType\IntegerField() | ||
), | ||
new Search\Field( | ||
'mime_type', | ||
$field->value->externalData["mimeType"], | ||
new Search\FieldType\StringField() | ||
), | ||
); | ||
} | ||
|
||
/** | ||
* Get index field types for search backend | ||
* | ||
* @return \eZ\Publish\SPI\Search\FieldType[] | ||
*/ | ||
public function getIndexDefinition() | ||
{ | ||
return array( | ||
'file_name' => new Search\FieldType\StringField(), | ||
'file_size' => new Search\FieldType\IntegerField(), | ||
'mime_type' => 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 "file_name"; | ||
} | ||
} |
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