/
SearchField.php
74 lines (69 loc) · 2.1 KB
/
SearchField.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<?php
/**
* File containing the MapLocation SearchField class
*
* @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\MapLocation;
use eZ\Publish\SPI\Persistence\Content\Field;
use eZ\Publish\SPI\FieldType\Indexable;
use eZ\Publish\SPI\Search;
/**
* Indexable definition for MapLocation field type
*/
class SearchField implements Indexable
{
/**
* Get index data for field for search backend
*
* @param \eZ\Publish\SPI\Persistence\Content\Field $field
*
* @return \eZ\Publish\SPI\Search\Field[]
*/
public function getIndexData( Field $field )
{
return array(
new Search\Field(
'value_address',
$field->value->externalData["address"],
new Search\FieldType\StringField()
),
new Search\Field(
'value_location',
array(
"latitude" => $field->value->externalData["latitude"],
"longitude" => $field->value->externalData["longitude"]
),
new Search\FieldType\GeoLocationField()
),
);
}
/**
* Get index field types for search backend
*
* @return \eZ\Publish\SPI\Search\FieldType[]
*/
public function getIndexDefinition()
{
return array(
'value_address' => new Search\FieldType\StringField(),
'value_location' => new Search\FieldType\GeoLocationField()
);
}
/**
* 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_address";
}
}