| Conditions | 9 |
| Paths | 7 |
| Total Lines | 34 |
| Code Lines | 17 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php namespace Anomaly\Streams\Platform\Search\Command; |
||
| 33 | public function handle(Application $application, Filesystem $files) |
||
| 34 | { |
||
| 35 | if (!class_exists('TeamTNT\TNTSearch\TNTSearch')) { |
||
| 36 | return; |
||
| 37 | } |
||
| 38 | |||
| 39 | if (!class_exists($this->stream->getEntryModelName())) { |
||
| 40 | return; |
||
| 41 | } |
||
| 42 | |||
| 43 | $model = $this->stream->getEntryModel(); |
||
| 44 | |||
| 45 | $index = $application->getStoragePath('search/' . $model->searchableAs() . '.index'); |
||
| 46 | |||
| 47 | if ($this->stream->isSearchable() && file_exists($index)) { |
||
| 48 | return; |
||
| 49 | } |
||
| 50 | |||
| 51 | if (!$this->stream->isSearchable() && file_exists($index)) { |
||
| 52 | $files->delete($index); |
||
| 53 | |||
| 54 | return; |
||
| 55 | } |
||
| 56 | |||
| 57 | if (!$this->stream->isSearchable()) { |
||
| 58 | return; |
||
| 59 | } |
||
| 60 | |||
| 61 | try { |
||
| 62 | app(EngineManager::class)->engine('tntsearch')->initIndex($model); |
||
| 63 | } catch (\Exception $e) { |
||
| 64 | // Kewl. |
||
| 65 | } |
||
| 66 | } |
||
| 67 | } |
||
| 68 |