Skip to content

Commit 5c3889e

Browse files
author
Mantas Urnieža
committed
Merge branch 'master' into v0.10
2 parents e96f176 + 79a3f7c commit 5c3889e

20 files changed

+381
-35
lines changed

Annotation/Document.php

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,15 @@
1111

1212
namespace ONGR\ElasticsearchBundle\Annotation;
1313

14+
use ONGR\ElasticsearchBundle\Mapping\DumperInterface;
15+
1416
/**
1517
* Annotation to mark a class as an Elasticsearch document.
1618
*
1719
* @Annotation
1820
* @Target("CLASS")
1921
*/
20-
final class Document
22+
final class Document implements DumperInterface
2123
{
2224
/**
2325
* @var bool
@@ -48,4 +50,37 @@ final class Document
4850
* @var array
4951
*/
5052
public $all;
53+
54+
/**
55+
* @var string
56+
*/
57+
public $dynamic;
58+
59+
/**
60+
* @var array
61+
*/
62+
public $transform;
63+
64+
/**
65+
* @var array
66+
*/
67+
public $dynamicDateFormats;
68+
69+
/**
70+
* {@inheritdoc}
71+
*/
72+
public function dump(array $exclude = [])
73+
{
74+
return array_diff_key(
75+
[
76+
'_ttl' => $this->ttl,
77+
'_all' => $this->all,
78+
'enabled' => $this->enabled,
79+
'dynamic' => $this->dynamic,
80+
'transform' => $this->transform,
81+
'dynamic_date_formats' => $this->dynamicDateFormats,
82+
],
83+
$exclude
84+
);
85+
}
5186
}

Document/AbstractDocument.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public function __clone()
106106
*
107107
* @param string $documentId
108108
*
109-
* @return DocumentInterface
109+
* @return $this
110110
*/
111111
public function setId($documentId)
112112
{
@@ -130,7 +130,7 @@ public function getId()
130130
*
131131
* @param string $documentScore
132132
*
133-
* @return DocumentInterface
133+
* @return $this
134134
*/
135135
public function setScore($documentScore)
136136
{
@@ -154,7 +154,7 @@ public function getScore()
154154
*
155155
* @param string $parent
156156
*
157-
* @return DocumentInterface
157+
* @return $this
158158
*/
159159
public function setParent($parent)
160160
{
@@ -214,7 +214,7 @@ public function getHighLight()
214214
*
215215
* @param string $ttl
216216
*
217-
* @return DocumentInterface
217+
* @return $this
218218
*/
219219
public function setTtl($ttl)
220220
{

Document/DocumentInterface.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ interface DocumentInterface
2323
*
2424
* @param string $documentId
2525
*
26-
* @return DocumentInterface
26+
* @return $this
2727
*/
2828
public function setId($documentId);
2929

@@ -39,7 +39,7 @@ public function getId();
3939
*
4040
* @param string $documentScore
4141
*
42-
* @return DocumentInterface
42+
* @return $this
4343
*/
4444
public function setScore($documentScore);
4545

@@ -55,7 +55,7 @@ public function getScore();
5555
*
5656
* @param string $parent
5757
*
58-
* @return DocumentInterface
58+
* @return $this
5959
*/
6060
public function setParent($parent);
6161

@@ -78,7 +78,7 @@ public function hasParent();
7878
*
7979
* @param int $ttl
8080
*
81-
* @return DocumentInterface
81+
* @return $this
8282
*/
8383
public function setTtl($ttl);
8484

Document/DocumentTrait.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public function __set($property, $value)
100100
*
101101
* @param string $documentId
102102
*
103-
* @return DocumentInterface
103+
* @return $this
104104
*/
105105
public function setId($documentId)
106106
{
@@ -124,7 +124,7 @@ public function getId()
124124
*
125125
* @param string $documentScore
126126
*
127-
* @return DocumentInterface
127+
* @return $this
128128
*/
129129
public function setScore($documentScore)
130130
{
@@ -148,7 +148,7 @@ public function getScore()
148148
*
149149
* @param string $parent
150150
*
151-
* @return DocumentInterface
151+
* @return $this
152152
*/
153153
public function setParent($parent)
154154
{
@@ -208,7 +208,7 @@ public function getHighLight()
208208
*
209209
* @param string $ttl
210210
*
211-
* @return DocumentInterface
211+
* @return $this
212212
*/
213213
public function setTtl($ttl)
214214
{

Document/Suggester/AbstractSuggester.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,14 @@ abstract class AbstractSuggester implements SuggesterInterface
5050
* Setter for input to store.
5151
*
5252
* @param string[]|string $input
53+
*
54+
* @return $this
5355
*/
5456
public function setInput($input)
5557
{
5658
$this->input = $input;
59+
60+
return $this;
5761
}
5862

5963
/**
@@ -70,10 +74,14 @@ public function getInput()
7074
* Setter for string to return.
7175
*
7276
* @param string $output
77+
*
78+
* @return $this
7379
*/
7480
public function setOutput($output)
7581
{
7682
$this->output = $output;
83+
84+
return $this;
7785
}
7886

7987
/**
@@ -90,10 +98,14 @@ public function getOutput()
9098
* Setter for object to be returned in the suggest option.
9199
*
92100
* @param object $payload
101+
*
102+
* @return $this
93103
*/
94104
public function setPayload($payload)
95105
{
96106
$this->payload = (object)$payload;
107+
108+
return $this;
97109
}
98110

99111
/**
@@ -110,10 +122,14 @@ public function getPayload()
110122
* Setter for a weight used to rank suggestions.
111123
*
112124
* @param int|string $weight
125+
*
126+
* @return $this
113127
*/
114128
public function setWeight($weight)
115129
{
116130
$this->weight = $weight;
131+
132+
return $this;
117133
}
118134

119135
/**

Document/Suggester/ContextSuggesterInterface.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ public function getContext();
2727
* Sets context to be used for completion.
2828
*
2929
* @param object $context
30+
*
31+
* @return $this
3032
*/
3133
public function setContext($context);
3234
}

Document/Suggester/ContextSuggesterTrait.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,13 @@ public function getContext()
3535
* Sets context to be used for completion.
3636
*
3737
* @param object $context
38+
*
39+
* @return $this
3840
*/
3941
public function setContext($context)
4042
{
4143
$this->context = $context;
44+
45+
return $this;
4246
}
4347
}

Document/Suggester/SuggesterInterface.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ interface SuggesterInterface
2020
* Setter for input to store.
2121
*
2222
* @param string $input
23+
*
24+
* @return $this
2325
*/
2426
public function setInput($input);
2527

@@ -34,6 +36,8 @@ public function getInput();
3436
* Setter for string to return.
3537
*
3638
* @param string $output
39+
*
40+
* @return $this
3741
*/
3842
public function setOutput($output);
3943

@@ -55,6 +59,8 @@ public function getWeight();
5559
* Setter for a weight used to rank suggestions.
5660
*
5761
* @param int|string $weight
62+
*
63+
* @return $this
5864
*/
5965
public function setWeight($weight);
6066

@@ -69,6 +75,8 @@ public function getPayload();
6975
* Setter for object to be returned in the suggest option.
7076
*
7177
* @param object $payload
78+
*
79+
* @return $this
7280
*/
7381
public function setPayload($payload);
7482
}

Document/Suggester/SuggesterTrait.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,14 @@ trait SuggesterTrait
5050
* Setter for input to store.
5151
*
5252
* @param string[]|string $input
53+
*
54+
* @return $this
5355
*/
5456
public function setInput($input)
5557
{
5658
$this->input = $input;
59+
60+
return $this;
5761
}
5862

5963
/**
@@ -70,10 +74,14 @@ public function getInput()
7074
* Setter for string to return.
7175
*
7276
* @param string $output
77+
*
78+
* @return $this
7379
*/
7480
public function setOutput($output)
7581
{
7682
$this->output = $output;
83+
84+
return $this;
7785
}
7886

7987
/**
@@ -90,10 +98,14 @@ public function getOutput()
9098
* Setter for object to be returned in the suggest option.
9199
*
92100
* @param object $payload
101+
*
102+
* @return $this
93103
*/
94104
public function setPayload($payload)
95105
{
96106
$this->payload = (object)$payload;
107+
108+
return $this;
97109
}
98110

99111
/**
@@ -110,10 +122,14 @@ public function getPayload()
110122
* Setter for a weight used to rank suggestions.
111123
*
112124
* @param int|string $weight
125+
*
126+
* @return $this
113127
*/
114128
public function setWeight($weight)
115129
{
116130
$this->weight = $weight;
131+
132+
return $this;
117133
}
118134

119135
/**

Mapping/DocumentParser.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -112,12 +112,10 @@ public function parse(\ReflectionClass $reflectionClass)
112112
return [
113113
$type => [
114114
'properties' => $properties,
115-
'fields' => [
116-
'_parent' => $parent === null ? null : ['type' => $parent],
117-
'_ttl' => $class->ttl,
118-
'enabled' => $class->enabled,
119-
'_all' => $class->all,
120-
],
115+
'fields' => array_merge(
116+
$class->dump(),
117+
['_parent' => $parent === null ? null : ['type' => $parent]]
118+
),
121119
'aliases' => $this->getAliases($reflectionClass),
122120
'objects' => $this->getObjects(),
123121
'proxyNamespace' => ProxyFactory::getProxyNamespace($reflectionClass, true),

0 commit comments

Comments
 (0)