| @@ 23-83 (lines=61) @@ | ||
| 20 | * @Annotation |
|
| 21 | * @Target("PROPERTY") |
|
| 22 | */ |
|
| 23 | final class Embedded |
|
| 24 | { |
|
| 25 | /** |
|
| 26 | * Inner object class name. |
|
| 27 | * |
|
| 28 | * @var string Object name to map |
|
| 29 | * |
|
| 30 | * @Required |
|
| 31 | */ |
|
| 32 | public $class; |
|
| 33 | ||
| 34 | /** |
|
| 35 | * Name of the type field. Defaults to normalized property name. |
|
| 36 | * |
|
| 37 | * @var string |
|
| 38 | */ |
|
| 39 | public $name; |
|
| 40 | ||
| 41 | /** |
|
| 42 | * Defines if related value will store a single object or an array of objects |
|
| 43 | * |
|
| 44 | * If this value is set to true, in the result ObjectIterator will be provided, |
|
| 45 | * otherwise you will get single object. |
|
| 46 | * |
|
| 47 | * @var bool Object or ObjectIterator |
|
| 48 | */ |
|
| 49 | public $multiple; |
|
| 50 | ||
| 51 | /** |
|
| 52 | * In this field you can define options. |
|
| 53 | * |
|
| 54 | * @var array |
|
| 55 | */ |
|
| 56 | public $options; |
|
| 57 | ||
| 58 | /** |
|
| 59 | * {@inheritdoc} |
|
| 60 | */ |
|
| 61 | public function dump(array $exclude = []) |
|
| 62 | { |
|
| 63 | $array = array_diff_key( |
|
| 64 | array_filter( |
|
| 65 | get_object_vars($this), |
|
| 66 | function ($value) { |
|
| 67 | return $value || is_bool($value); |
|
| 68 | } |
|
| 69 | ), |
|
| 70 | array_flip(array_merge(['class', 'name', 'multiple'], $exclude)) |
|
| 71 | ); |
|
| 72 | ||
| 73 | return array_combine( |
|
| 74 | array_map( |
|
| 75 | function ($key) { |
|
| 76 | return Caser::snake($key); |
|
| 77 | }, |
|
| 78 | array_keys($array) |
|
| 79 | ), |
|
| 80 | array_values($array) |
|
| 81 | ); |
|
| 82 | } |
|
| 83 | } |
|
| 84 | ||
| @@ 24-76 (lines=53) @@ | ||
| 21 | * @Annotation |
|
| 22 | * @Target("PROPERTY") |
|
| 23 | */ |
|
| 24 | final class Property |
|
| 25 | { |
|
| 26 | /** |
|
| 27 | * Field type. |
|
| 28 | * |
|
| 29 | * @var string |
|
| 30 | * |
|
| 31 | * @Required |
|
| 32 | * @Enum({"string", "boolean", "integer", "float", "long", "short", "byte", "double", "date", |
|
| 33 | * "geo_point", "geo_shape", "ip", "binary", "token_count" }) |
|
| 34 | */ |
|
| 35 | public $type; |
|
| 36 | ||
| 37 | /** |
|
| 38 | * Name of the type field. Defaults to normalized property name. |
|
| 39 | * |
|
| 40 | * @var string |
|
| 41 | */ |
|
| 42 | public $name; |
|
| 43 | ||
| 44 | /** |
|
| 45 | * In this field you can define options (like analyzers and etc) for specific field types. |
|
| 46 | * |
|
| 47 | * @var array |
|
| 48 | */ |
|
| 49 | public $options; |
|
| 50 | ||
| 51 | /** |
|
| 52 | * {@inheritdoc} |
|
| 53 | */ |
|
| 54 | public function dump(array $exclude = []) |
|
| 55 | { |
|
| 56 | $array = array_diff_key( |
|
| 57 | array_filter( |
|
| 58 | get_object_vars($this), |
|
| 59 | function ($value) { |
|
| 60 | return $value || is_bool($value); |
|
| 61 | } |
|
| 62 | ), |
|
| 63 | array_flip(array_merge(['name'], $exclude)) |
|
| 64 | ); |
|
| 65 | ||
| 66 | return array_combine( |
|
| 67 | array_map( |
|
| 68 | function ($key) { |
|
| 69 | return Caser::snake($key); |
|
| 70 | }, |
|
| 71 | array_keys($array) |
|
| 72 | ), |
|
| 73 | array_values($array) |
|
| 74 | ); |
|
| 75 | } |
|
| 76 | } |
|
| 77 | ||