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