hasMaintainer() || $manager->unavailableReason() !== null) { return null; } $requested ??= (bool) $this->option('rebuild-search-index'); if ($requested) { $report = $manager->repairStale(); $this->reportRebuild($report); return $report; } $this->warnStale($manager->inspect()); return null; } /** * 재생성하지 않은 경우, 색인 누락 사실만 안내합니다. * * @param array $results 점검 결과 * @return void */ private function warnStale(array $results): void { $stale = array_values(array_filter($results, fn (SearchIndexHealth $h) => $h->needsRebuild())); if ($stale === []) { return; } $this->newLine(); $this->warn('⚠️ '.__('search.index.stale_after_update', ['count' => count($stale)])); foreach ($stale as $health) { $this->line(' - '.$health->identifier); } $this->line(' '.__('search.index.stale_hint')); } /** * 재생성 보고를 콘솔에 출력합니다. * * @param SearchIndexRepairReport $report 재생성 보고 * @return void */ private function reportRebuild(SearchIndexRepairReport $report): void { $this->newLine(); if (! $report->didRebuild()) { $this->info('✅ '.$report->summary()); return; } $this->info('✅ '.$report->summary()); foreach ($report->repaired as $identifier) { $this->line(' '.__('search.index.rebuilt_item', ['index' => $identifier])); } foreach ($report->failed as $identifier => $message) { $this->error(' '.__('search.index.rebuild_failed_item', ['index' => $identifier, 'error' => $message])); } foreach ($report->remaining as $identifier) { $this->warn(' '.__('search.index.still_stale_item', ['index' => $identifier])); } } }