1 | <?php |
||
30 | abstract class AbstractBaseRequest implements RequestInterface |
||
31 | { |
||
32 | /** |
||
33 | * @var \Elastification\Client\Serializer\SerializerInterface |
||
34 | */ |
||
35 | protected $serializer; |
||
36 | |||
37 | /** |
||
38 | * @var array |
||
39 | */ |
||
40 | protected $serializerParams = array(); |
||
41 | |||
42 | /** |
||
43 | * @var null|string |
||
44 | */ |
||
45 | protected $index = null; |
||
46 | |||
47 | /** |
||
48 | * @var null|string |
||
49 | */ |
||
50 | protected $type = null; |
||
51 | |||
52 | /** |
||
53 | * @var array |
||
54 | */ |
||
55 | protected $parameters = array(); |
||
56 | |||
57 | /** |
||
58 | * @param string $index |
||
59 | * @param string $type |
||
60 | * @param \Elastification\Client\Serializer\SerializerInterface $serializer |
||
61 | * @param array $serializerParams |
||
62 | * |
||
63 | * @author Daniel Wendlandt |
||
64 | */ |
||
65 | 1473 | public function __construct($index, $type, SerializerInterface $serializer, array $serializerParams = array()) |
|
66 | { |
||
67 | 1473 | $this->serializer = $serializer; |
|
68 | 1473 | if ($serializer instanceof JmsSerializer) { |
|
69 | 8 | $this->serializerParams = array_merge(['index' => $index, 'type' => $type], $serializerParams); |
|
70 | 8 | } else { |
|
71 | 1473 | $this->serializerParams = $serializerParams; |
|
72 | } |
||
73 | |||
74 | 1473 | if (!empty($index)) { |
|
75 | 1115 | $this->index = $index; |
|
76 | 1115 | } |
|
77 | |||
78 | 1473 | if (!empty($type)) { |
|
79 | 547 | $this->type = $type; |
|
80 | 547 | } |
|
81 | 1473 | } |
|
82 | |||
83 | /** |
||
84 | * @inheritdoc |
||
85 | */ |
||
86 | 90 | public function getIndex() |
|
90 | |||
91 | /** |
||
92 | * @inheritdoc |
||
93 | */ |
||
94 | 79 | public function getType() |
|
98 | |||
99 | /** |
||
100 | * @inheritdoc |
||
101 | */ |
||
102 | 157 | public function getSerializer() |
|
103 | { |
||
104 | 157 | return $this->serializer; |
|
105 | } |
||
106 | |||
107 | /** |
||
108 | * @inheritdoc |
||
109 | */ |
||
110 | 156 | public function getSerializerParams() |
|
114 | |||
115 | /** |
||
116 | * Sets a parameter and casts value to string |
||
117 | * |
||
118 | * @param string $name |
||
119 | * @param mixed $value |
||
120 | * @author Daniel Wendlandt |
||
121 | */ |
||
122 | 330 | public function setParameter($name, $value) |
|
126 | |||
127 | /** |
||
128 | * Getter for parameters |
||
129 | * |
||
130 | * @return array |
||
131 | * @author Daniel Wendlandt |
||
132 | */ |
||
133 | 40 | public function getParameters() |
|
137 | } |
||
138 |