diff --git a/src/EventSubscriber/SlackNotifySubscriber.php b/src/EventSubscriber/SlackNotifySubscriber.php index 5544546..a351cd5 100644 --- a/src/EventSubscriber/SlackNotifySubscriber.php +++ b/src/EventSubscriber/SlackNotifySubscriber.php @@ -26,13 +26,13 @@ class SlackNotifySubscriber implements EventSubscriberInterface private $warehouseRepository; - public function __construct(string $slackWebhookUrl, ProductRepository $productRepository, StockRepository $stockRepository, WarehouseRepository $warehouseRepository) + public function __construct(string $slackWebhookUrl, ProductRepository $productRepository, StockRepository $stockRepository, WarehouseRepository $warehouseRepository, LoggerInterface $logger) { $this->slackWebhookUrl = $slackWebhookUrl; $this->productRepository = $productRepository; $this->stockRepository = $stockRepository; $this->warehouseRepository = $warehouseRepository; - + $this->logger = $logger; } public static function getSubscribedEvents(): array @@ -65,6 +65,7 @@ class SlackNotifySubscriber implements EventSubscriberInterface $warehouse = $this->getWarehouseByGtin($item['gtin']); if ($warehouse == false) { + $this->logger->error('Warehouse not found for GTIN: ' . $item['gtin']); continue; } @@ -82,9 +83,7 @@ class SlackNotifySubscriber implements EventSubscriberInterface $msg .= ' - ' . $item['han']; $msg .= ' * - ' . $item['menge'] . "* \n"; - $slack->from('CDS-Notify')->send($msg); - } } } @@ -92,14 +91,14 @@ class SlackNotifySubscriber implements EventSubscriberInterface /** * @param string $gtin - * @return array + * @return string|bool */ - private function getWarehouseByGtin(string $gtin) + private function getWarehouseByGtin(string $gtin): bool|string { if ($gtin == null) { return false; } - $warehouse = ""; + $warehouse = false; $product = $this->productRepository->findOneBy(['gtin' => $gtin]); @@ -125,4 +124,4 @@ class SlackNotifySubscriber implements EventSubscriberInterface return $warehouse; } -} +} \ No newline at end of file