| Conditions | 4 |
| Paths | 4 |
| Total Lines | 23 |
| Code Lines | 17 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 41 | public function handle() |
||
| 42 | { |
||
| 43 | $elasticSearch = ElasticSearchBuilder::create()->setHosts(Config::get('elasticsearch.hosts'))->build()->indices(); |
||
| 44 | |||
| 45 | $index = Config::get('elasticsearch.index'); |
||
| 46 | if ($elasticSearch->exists(['index' => $index])) { |
||
| 47 | $this->error(sprintf('The "%s" index already exists', $index)); |
||
| 48 | return; |
||
| 49 | } |
||
| 50 | $params = Config::get('elasticsearch.' . $index); |
||
| 51 | |||
| 52 | if (!empty($params)) { |
||
| 53 | try { |
||
| 54 | $elasticSearch->create($params); |
||
| 55 | } catch (Exception $e) { |
||
| 56 | $this->error($e->getMessage()); |
||
| 57 | return; |
||
| 58 | } |
||
| 59 | $this->info(sprintf('"%s" index created successfully', $index)); |
||
| 60 | return; |
||
| 61 | } else { |
||
| 62 | $this->warn(sprintf('"%s" index configuration not found', $index)); |
||
| 63 | return; |
||
| 64 | } |
||
| 67 |