From 865592d1f2d423b37e0419ef79c051747ca1a886 Mon Sep 17 00:00:00 2001 From: Matt Lang Date: Thu, 18 Jul 2024 11:39:37 +1200 Subject: [PATCH] fix use get instead of create for logger instances --- src/Extensions/AlgoliaObjectExtension.php | 4 ++-- src/Jobs/AlgoliaDeleteItemJob.php | 2 +- src/Service/AlgoliaIndexer.php | 2 +- src/Service/AlgoliaPageCrawler.php | 2 +- src/Service/AlgoliaService.php | 4 ++-- src/Tasks/AlgoliaReindex.php | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Extensions/AlgoliaObjectExtension.php b/src/Extensions/AlgoliaObjectExtension.php index 09dcd61..b35e261 100644 --- a/src/Extensions/AlgoliaObjectExtension.php +++ b/src/Extensions/AlgoliaObjectExtension.php @@ -236,7 +236,7 @@ public function doImmediateIndexInAlgolia(): bool return true; } } catch (Throwable $e) { - Injector::inst()->create(LoggerInterface::class)->error($e); + Injector::inst()->get(LoggerInterface::class)->error($e); $schema = DataObject::getSchema(); $table = $schema->tableForField($this->owner->ClassName, 'AlgoliaError'); @@ -291,7 +291,7 @@ public function removeFromAlgolia(): bool $this->markAsRemovedFromAlgoliaIndex(); } catch (Throwable $e) { - Injector::inst()->create(LoggerInterface::class)->error($e); + Injector::inst()->get(LoggerInterface::class)->error($e); return false; } diff --git a/src/Jobs/AlgoliaDeleteItemJob.php b/src/Jobs/AlgoliaDeleteItemJob.php index 09ee3c4..4ad6a66 100644 --- a/src/Jobs/AlgoliaDeleteItemJob.php +++ b/src/Jobs/AlgoliaDeleteItemJob.php @@ -55,7 +55,7 @@ public function process() $indexer = Injector::inst()->create(AlgoliaIndexer::class); $indexer->deleteItem($this->itemClass, $this->itemUUID); } catch (Throwable $e) { - Injector::inst()->create(LoggerInterface::class)->error($e); + Injector::inst()->get(LoggerInterface::class)->error($e); } $this->isComplete = true; diff --git a/src/Service/AlgoliaIndexer.php b/src/Service/AlgoliaIndexer.php index d14d3cb..0399dcb 100644 --- a/src/Service/AlgoliaIndexer.php +++ b/src/Service/AlgoliaIndexer.php @@ -324,7 +324,7 @@ public function exportAttributesFromRelationship($item, $relationship, $attribut $attributes->push($relationship, $data); } catch (Throwable $e) { - Injector::inst()->create(LoggerInterface::class)->error($e); + Injector::inst()->get(LoggerInterface::class)->error($e); } } diff --git a/src/Service/AlgoliaPageCrawler.php b/src/Service/AlgoliaPageCrawler.php index 14575fa..828e41a 100644 --- a/src/Service/AlgoliaPageCrawler.php +++ b/src/Service/AlgoliaPageCrawler.php @@ -117,7 +117,7 @@ public function getMainContent(): string } } } catch (Throwable $e) { - Injector::inst()->create(LoggerInterface::class)->error($e); + Injector::inst()->get(LoggerInterface::class)->error($e); } SSViewer::set_themes($oldThemes); diff --git a/src/Service/AlgoliaService.php b/src/Service/AlgoliaService.php index d6c5c01..fced815 100644 --- a/src/Service/AlgoliaService.php +++ b/src/Service/AlgoliaService.php @@ -141,7 +141,7 @@ public function initIndexes($item = null, $excludeReplicas = true) return []; } } catch (Throwable $e) { - Injector::inst()->create(LoggerInterface::class)->error($e); + Injector::inst()->get(LoggerInterface::class)->error($e); if (Director::isDev()) { Debug::message($e->getMessage()); @@ -277,7 +277,7 @@ function ($replica) { $index->setSettings($data['indexSettings']); } catch (Throwable $e) { - Injector::inst()->create(LoggerInterface::class)->error($e); + Injector::inst()->get(LoggerInterface::class)->error($e); return false; diff --git a/src/Tasks/AlgoliaReindex.php b/src/Tasks/AlgoliaReindex.php index 4ee5030..151a693 100644 --- a/src/Tasks/AlgoliaReindex.php +++ b/src/Tasks/AlgoliaReindex.php @@ -308,7 +308,7 @@ public function indexBatch($indexName, $items): bool return true; } catch (Throwable $e) { - Injector::inst()->create(LoggerInterface::class)->error($e); + Injector::inst()->get(LoggerInterface::class)->error($e); if (Director::isDev()) { Debug::message($e->getMessage());