fixes
This commit is contained in:
parent
99551c9e31
commit
c4db83daec
@ -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]);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user