Skip to content

Commit d68ce14

Browse files
committed
[+]: Support For Parameters [+]: Refactor Collection & Config [+]: Index add support for parameters
1 parent 05570f1 commit d68ce14

File tree

11 files changed

+421
-452
lines changed

11 files changed

+421
-452
lines changed

src/Builder/ContainerBuilder.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ protected function createConnections(Container $container, array $config): self
8282
foreach ($connections as $id => $config) {
8383
$entry = new Connection($id, $config, $this->logger);
8484

85-
$container->connections()->set($entry->id(), $entry);
85+
$container->connections()->put($entry->id(), $entry);
8686

8787
$this->logger->debug(\vsprintf('Connection with ID: "%s" has been created', [$entry->id()]));
8888
}
@@ -108,6 +108,7 @@ protected function createMappings(Container $container, array $config): self
108108
'params' => [],
109109
'aliases' => [],
110110
'type' => null,
111+
'parameters' => [],
111112
];
112113

113114
foreach ($mappings as $id => $mapping) {
@@ -140,7 +141,7 @@ protected function createMappings(Container $container, array $config): self
140141

141142
$entry = new $instance($id, $name, $params, $aliases, $type, $this->logger);
142143

143-
$container->mappings()->set($entry->id(), $entry);
144+
$container->mappings()->put($entry->id(), $entry);
144145

145146
$this->logger->debug(\vsprintf('Mapping with ID: "%s" has been created', [$entry->id()]));
146147
}//end foreach
@@ -167,6 +168,7 @@ protected function createIndices(Container $container, array $config): self
167168
'mapping' => null,
168169
'config' => [],
169170
'connection' => null,
171+
'params' => [],
170172
];
171173

172174
foreach ($indices as $id => $index) {
@@ -225,12 +227,13 @@ protected function createIndices(Container $container, array $config): self
225227
$name = $index['name'];
226228
$group = $index['group'];
227229
$mapping = $container->mappings()->getIfSet((string) $index['mapping']);
228-
$params = $index['config'];
230+
$config = $index['config'];
229231
$connection = $container->connections()->get($index['connection']);
232+
$params = (array) $index['params'];
230233

231-
$entry = new $instance($id, $name, $connection, $mapping, $group, $params, $this->logger);
234+
$entry = new $instance($id, $name, $connection, $mapping, $group, $config, $params, $this->logger);
232235

233-
$container->indices()->set($entry->id(), $entry);
236+
$container->indices()->put($entry->id(), $entry);
234237

235238
$this->logger->debug(\vsprintf('Index with ID: "%s" has been created', [$entry->id()]));
236239
}//end foreach

src/Collection/Collection.php

Lines changed: 0 additions & 114 deletions
This file was deleted.

src/Collection/ConnectionCollection.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@
55
namespace BinaryCube\ElasticTool\Collection;
66

77
use BinaryCube\ElasticTool\Connection;
8+
use BinaryCube\ElasticTool\Support\Collection;
89

910
/**
1011
* Class ConnectionCollection
1112
*
12-
* @method Connection[] __invoke()
13-
* @method $this set(string $id, Connection $item)
14-
* @method $this remove(string $id)
15-
* @method Connection get(string $id)
13+
* @method Connection[] __invoke()
14+
* @method $this put(string $id, Connection $item)
15+
* @method $this forget(string $id)
16+
* @method Connection get(string $id, $default = null)
1617
* @method Connection|mixed getIfSet(string $id, $default = null)
1718
* @method Connection[] all()()
1819
* @method $this clear()

src/Collection/IndexCollection.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@
55
namespace BinaryCube\ElasticTool\Collection;
66

77
use BinaryCube\ElasticTool\Index;
8+
use BinaryCube\ElasticTool\Support\Collection;
89

910
/**
1011
* Class IndexCollection
1112
*
1213
* @method Index[] __invoke()
13-
* @method $this set(string $id, Index $item)
14-
* @method $this remove(string $id)
15-
* @method Index get(string $id)
14+
* @method $this put(string $id, Index $item)
15+
* @method $this forget(string $id)
16+
* @method Index get(string $id, $default = null)
1617
* @method Index|mixed getIfSet(string $id, $default = null)
1718
* @method Index[] all()()
1819
* @method $this clear()

src/Collection/MappingCollection.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,19 @@
55
namespace BinaryCube\ElasticTool\Collection;
66

77
use BinaryCube\ElasticTool\Mapping;
8+
use BinaryCube\ElasticTool\Support\Collection;
89

910
/**
1011
* Class MappingCollection
1112
*
1213
* @method Mapping[] __invoke()
13-
* @method $this set(string $id, Mapping $item)
14-
* @method $this remove(string $id)
15-
* @method Mapping get(string $id)
14+
* @method $this put(string $id, Mapping $item)
15+
* @method $this forget(string $id)
16+
* @method Mapping get(string $id, $default = null)
1617
* @method Mapping|mixed getIfSet(string $id, $default = null)
1718
* @method Mapping[] all()()
18-
* @method $this clear()
19-
* @method bool has(string $id)
19+
* @method $this clear()
20+
* @method bool has(string $id)
2021
*/
2122
class MappingCollection extends Collection
2223
{

0 commit comments

Comments
 (0)