fixes
This commit is contained in:
parent
99551c9e31
commit
c4db83daec
@ -26,13 +26,13 @@ class SlackNotifySubscriber implements EventSubscriberInterface
|
|||||||
private $warehouseRepository;
|
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->slackWebhookUrl = $slackWebhookUrl;
|
||||||
$this->productRepository = $productRepository;
|
$this->productRepository = $productRepository;
|
||||||
$this->stockRepository = $stockRepository;
|
$this->stockRepository = $stockRepository;
|
||||||
$this->warehouseRepository = $warehouseRepository;
|
$this->warehouseRepository = $warehouseRepository;
|
||||||
|
$this->logger = $logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getSubscribedEvents(): array
|
public static function getSubscribedEvents(): array
|
||||||
@ -65,6 +65,7 @@ class SlackNotifySubscriber implements EventSubscriberInterface
|
|||||||
$warehouse = $this->getWarehouseByGtin($item['gtin']);
|
$warehouse = $this->getWarehouseByGtin($item['gtin']);
|
||||||
|
|
||||||
if ($warehouse == false) {
|
if ($warehouse == false) {
|
||||||
|
$this->logger->error('Warehouse not found for GTIN: ' . $item['gtin']);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,9 +83,7 @@ class SlackNotifySubscriber implements EventSubscriberInterface
|
|||||||
$msg .= ' - ' . $item['han'];
|
$msg .= ' - ' . $item['han'];
|
||||||
$msg .= ' * - ' . $item['menge'] . "* \n";
|
$msg .= ' * - ' . $item['menge'] . "* \n";
|
||||||
|
|
||||||
|
|
||||||
$slack->from('CDS-Notify')->send($msg);
|
$slack->from('CDS-Notify')->send($msg);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -92,14 +91,14 @@ class SlackNotifySubscriber implements EventSubscriberInterface
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $gtin
|
* @param string $gtin
|
||||||
* @return array
|
* @return string|bool
|
||||||
*/
|
*/
|
||||||
private function getWarehouseByGtin(string $gtin)
|
private function getWarehouseByGtin(string $gtin): bool|string
|
||||||
{
|
{
|
||||||
if ($gtin == null) {
|
if ($gtin == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$warehouse = "";
|
$warehouse = false;
|
||||||
|
|
||||||
$product = $this->productRepository->findOneBy(['gtin' => $gtin]);
|
$product = $this->productRepository->findOneBy(['gtin' => $gtin]);
|
||||||
|
|
||||||
@ -125,4 +124,4 @@ class SlackNotifySubscriber implements EventSubscriberInterface
|
|||||||
return $warehouse;
|
return $warehouse;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user