From b5f1ba6f87eaf93fc7b10ee794c58b5414416c4b Mon Sep 17 00:00:00 2001 From: Marko <52066939+HeX87@users.noreply.github.com> Date: Fri, 2 Aug 2024 09:46:16 +0200 Subject: [PATCH] add Logging --- src/Command/HiltesExportCommand.php | 6 ++- src/Command/HiltesImportCommand.php | 6 +-- src/Command/JtlExportCommand.php | 5 +- src/Entity/Order.php | 3 +- src/Entity/Product.php | 2 +- src/Entity/Stock.php | 2 +- src/Entity/Warehouse.php | 2 +- .../ExportHiltesSubscriber.php | 2 +- src/EventSubscriber/SlackNotifySubscriber.php | 3 +- src/Helper/Ftp.php | 3 +- src/Helper/Hiltes.php | 15 +++--- src/Helper/HiltesImport.php | 3 +- src/Helper/Jtl.php | 7 ++- src/Repository/HlsCountryRepository.php | 46 +++++++++--------- src/Repository/OrderRepository.php | 48 +++++++++---------- src/Repository/ProductRepository.php | 2 +- src/Repository/SettingsRepository.php | 46 +++++++++--------- src/Repository/StockRepository.php | 2 +- src/Repository/WarehouseRepository.php | 20 ++++---- src/Security/ApiKeyAuthenticator.php | 3 +- 20 files changed, 110 insertions(+), 116 deletions(-) diff --git a/src/Command/HiltesExportCommand.php b/src/Command/HiltesExportCommand.php index dea2c58..c843a97 100644 --- a/src/Command/HiltesExportCommand.php +++ b/src/Command/HiltesExportCommand.php @@ -61,7 +61,9 @@ class HiltesExportCommand extends Command foreach ($orders as $order) { - if ($order->getStatus() > 0) continue; + if ($order->getStatus() > 0) { + continue; + } $tA = $order->getData();#json_decode($order->getData()); $tA['orderdate'] = "2023-08-30T12:05:24.000Z"; @@ -180,4 +182,4 @@ class HiltesExportCommand extends Command return Command::SUCCESS; } -} \ No newline at end of file +} diff --git a/src/Command/HiltesImportCommand.php b/src/Command/HiltesImportCommand.php index 2ca044e..16d7298 100644 --- a/src/Command/HiltesImportCommand.php +++ b/src/Command/HiltesImportCommand.php @@ -17,6 +17,7 @@ use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; use Symfony\Component\HttpKernel\KernelInterface; + use function Sentry\captureCheckIn; #[AsCommand( @@ -35,8 +36,7 @@ class HiltesImportCommand extends Command StockRepository $stockRepository, WarehouseRepository $warehouseRepository, LoggerInterface $logger - ) - { + ) { $this->productRepository = $productRepository; $this->stockRepository = $stockRepository; $this->warehouseRepository = $warehouseRepository; @@ -125,4 +125,4 @@ class HiltesImportCommand extends Command //POST: $dirs = /app/public return implode('/', $dirs); } -} \ No newline at end of file +} diff --git a/src/Command/JtlExportCommand.php b/src/Command/JtlExportCommand.php index 0cfd8c3..95c48d7 100644 --- a/src/Command/JtlExportCommand.php +++ b/src/Command/JtlExportCommand.php @@ -32,8 +32,7 @@ class JtlExportCommand extends Command StockRepository $stockRepository, WarehouseRepository $warehouseRepository, LoggerInterface $logger - ) - { + ) { $this->productRepository = $productRepository; $this->stockRepository = $stockRepository; $this->warehouseRepository = $warehouseRepository; @@ -85,4 +84,4 @@ class JtlExportCommand extends Command return implode('/', $dirs); } -} \ No newline at end of file +} diff --git a/src/Entity/Order.php b/src/Entity/Order.php index d80a0cd..babdb72 100644 --- a/src/Entity/Order.php +++ b/src/Entity/Order.php @@ -9,7 +9,6 @@ use DateTimeInterface; use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Mapping as ORM; - /* * Bestellungen Status: * 1 = Bestellung eingegangen @@ -108,4 +107,4 @@ class Order return $this; } -} \ No newline at end of file +} diff --git a/src/Entity/Product.php b/src/Entity/Product.php index fef833a..42e1da7 100644 --- a/src/Entity/Product.php +++ b/src/Entity/Product.php @@ -60,4 +60,4 @@ class Product return $this; } -} \ No newline at end of file +} diff --git a/src/Entity/Stock.php b/src/Entity/Stock.php index dbbb93d..f9b719d 100644 --- a/src/Entity/Stock.php +++ b/src/Entity/Stock.php @@ -126,4 +126,4 @@ class Stock return $this; } -} \ No newline at end of file +} diff --git a/src/Entity/Warehouse.php b/src/Entity/Warehouse.php index 04c0e1d..a6d29a8 100644 --- a/src/Entity/Warehouse.php +++ b/src/Entity/Warehouse.php @@ -93,4 +93,4 @@ class Warehouse return $this; } -} \ No newline at end of file +} diff --git a/src/EventSubscriber/ExportHiltesSubscriber.php b/src/EventSubscriber/ExportHiltesSubscriber.php index f0091af..99108b4 100644 --- a/src/EventSubscriber/ExportHiltesSubscriber.php +++ b/src/EventSubscriber/ExportHiltesSubscriber.php @@ -40,4 +40,4 @@ class ExportHiltesSubscriber implements EventSubscriberInterface KernelEvents::VIEW => ['onPatchOrder', EventPriorities::POST_WRITE] ]; } -} \ No newline at end of file +} diff --git a/src/EventSubscriber/SlackNotifySubscriber.php b/src/EventSubscriber/SlackNotifySubscriber.php index 6e9e44b..5544546 100644 --- a/src/EventSubscriber/SlackNotifySubscriber.php +++ b/src/EventSubscriber/SlackNotifySubscriber.php @@ -15,7 +15,6 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\Event\ViewEvent; use Symfony\Component\HttpKernel\KernelEvents; - class SlackNotifySubscriber implements EventSubscriberInterface { /** @@ -126,4 +125,4 @@ class SlackNotifySubscriber implements EventSubscriberInterface return $warehouse; } -} \ No newline at end of file +} diff --git a/src/Helper/Ftp.php b/src/Helper/Ftp.php index 115f18c..1e7b113 100644 --- a/src/Helper/Ftp.php +++ b/src/Helper/Ftp.php @@ -2,7 +2,6 @@ namespace App\Helper; - use Exception; class Ftp @@ -130,4 +129,4 @@ class Ftp { $this->remoteDir = $remoteDir; } -} \ No newline at end of file +} diff --git a/src/Helper/Hiltes.php b/src/Helper/Hiltes.php index 3c09018..fc0a39f 100644 --- a/src/Helper/Hiltes.php +++ b/src/Helper/Hiltes.php @@ -9,7 +9,6 @@ use Symfony\Component\Filesystem\Exception\IOExceptionInterface; use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\Finder\Finder; - class Hiltes { // init file system @@ -37,7 +36,7 @@ class Hiltes * @param string $data * @return void */ - public function export(string $data) : void + public function export(string $data): void { try { $new_file_path = $this->current_dir_path . "/hiltes/c2h/" . $this->createFileName(); @@ -114,8 +113,8 @@ class Hiltes $tSalNr = array(); foreach ($tA['positions'] as $v) { if ($v['type'] == 'versandposition' || $v['sku'] == '') { -// $SalesNumber = '000001'; -// $SalesGoodsGroupNumber = 9350; + // $SalesNumber = '000001'; + // $SalesGoodsGroupNumber = 9350; // Versandkosten werden nicht übermittelt continue; @@ -234,7 +233,7 @@ class Hiltes $payload = json_encode($param); if ($auth) { - $this->logger->info('Send Order ' . $url . ' ' . $payload); + $this->logger->info('Send Order ' . $url . ' ' . $payload); } curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json', $authorization)); @@ -258,7 +257,7 @@ class Hiltes * @param mixed $data The data to be converted to JSON. * @return array The JSON object. */ - public function createJson($data) : array + public function createJson($data): array { $arr = array( 'File' => array( @@ -375,7 +374,7 @@ class Hiltes try { //Status 3 für erfolgreich exportiert $order->setStatus(3); - // $order->setHiltes($t); + // $order->setHiltes($t); $this->orderRepository->update($order, true); } catch (\Exception $exception) { @@ -402,4 +401,4 @@ class Hiltes } } -} \ No newline at end of file +} diff --git a/src/Helper/HiltesImport.php b/src/Helper/HiltesImport.php index 3c98521..b6dd9b5 100644 --- a/src/Helper/HiltesImport.php +++ b/src/Helper/HiltesImport.php @@ -2,7 +2,6 @@ namespace App\Helper; - use App\Entity\Product; use App\Entity\Stock; use App\Entity\Warehouse; @@ -323,4 +322,4 @@ class HiltesImport return false; } -} \ No newline at end of file +} diff --git a/src/Helper/Jtl.php b/src/Helper/Jtl.php index 461ddd0..5fef56b 100644 --- a/src/Helper/Jtl.php +++ b/src/Helper/Jtl.php @@ -12,7 +12,6 @@ use Exception; use League\Csv\Writer; use Psr\Log\LoggerInterface; - class Jtl { private $productRepository; @@ -45,8 +44,8 @@ class Jtl WarehouseRepository $warehouseRepository, StockRepository $stockRepository, LoggerInterface $logger, - string $rootPath) - { + string $rootPath + ) { $this->productRepository = $productRepository; $this->warehouseRepository = $warehouseRepository; $this->stockRepository = $stockRepository; @@ -128,4 +127,4 @@ class Jtl $this->logger->error($e->getMessage()); } } -} \ No newline at end of file +} diff --git a/src/Repository/HlsCountryRepository.php b/src/Repository/HlsCountryRepository.php index d271f13..de32f82 100644 --- a/src/Repository/HlsCountryRepository.php +++ b/src/Repository/HlsCountryRepository.php @@ -39,28 +39,28 @@ class HlsCountryRepository extends ServiceEntityRepository } } -// /** -// * @return HlsCountry[] Returns an array of HlsCountry objects -// */ -// public function findByExampleField($value): array -// { -// return $this->createQueryBuilder('h') -// ->andWhere('h.exampleField = :val') -// ->setParameter('val', $value) -// ->orderBy('h.id', 'ASC') -// ->setMaxResults(10) -// ->getQuery() -// ->getResult() -// ; -// } + // /** + // * @return HlsCountry[] Returns an array of HlsCountry objects + // */ + // public function findByExampleField($value): array + // { + // return $this->createQueryBuilder('h') + // ->andWhere('h.exampleField = :val') + // ->setParameter('val', $value) + // ->orderBy('h.id', 'ASC') + // ->setMaxResults(10) + // ->getQuery() + // ->getResult() + // ; + // } -// public function findOneBySomeField($value): ?HlsCountry -// { -// return $this->createQueryBuilder('h') -// ->andWhere('h.exampleField = :val') -// ->setParameter('val', $value) -// ->getQuery() -// ->getOneOrNullResult() -// ; -// } + // public function findOneBySomeField($value): ?HlsCountry + // { + // return $this->createQueryBuilder('h') + // ->andWhere('h.exampleField = :val') + // ->setParameter('val', $value) + // ->getQuery() + // ->getOneOrNullResult() + // ; + // } } diff --git a/src/Repository/OrderRepository.php b/src/Repository/OrderRepository.php index 4090f99..15d59ae 100644 --- a/src/Repository/OrderRepository.php +++ b/src/Repository/OrderRepository.php @@ -59,30 +59,30 @@ class OrderRepository extends ServiceEntityRepository } } -// /** -// * @return Order[] Returns an array of Order objects -// */ -// public function findByExampleField($value): array -// { -// return $this->createQueryBuilder('o') -// ->andWhere('o.exampleField = :val') -// ->setParameter('val', $value) -// ->orderBy('o.id', 'ASC') -// ->setMaxResults(10) -// ->getQuery() -// ->getResult() -// ; -// } + // /** + // * @return Order[] Returns an array of Order objects + // */ + // public function findByExampleField($value): array + // { + // return $this->createQueryBuilder('o') + // ->andWhere('o.exampleField = :val') + // ->setParameter('val', $value) + // ->orderBy('o.id', 'ASC') + // ->setMaxResults(10) + // ->getQuery() + // ->getResult() + // ; + // } -// public function findOneBySomeField($value): ?Order -// { -// return $this->createQueryBuilder('o') -// ->andWhere('o.exampleField = :val') -// ->setParameter('val', $value) -// ->getQuery() -// ->getOneOrNullResult() -// ; -// } + // public function findOneBySomeField($value): ?Order + // { + // return $this->createQueryBuilder('o') + // ->andWhere('o.exampleField = :val') + // ->setParameter('val', $value) + // ->getQuery() + // ->getOneOrNullResult() + // ; + // } /** * @throws Exception */ @@ -90,4 +90,4 @@ class OrderRepository extends ServiceEntityRepository { throw new Exception($string); } -} \ No newline at end of file +} diff --git a/src/Repository/ProductRepository.php b/src/Repository/ProductRepository.php index a2cc408..dcce359 100644 --- a/src/Repository/ProductRepository.php +++ b/src/Repository/ProductRepository.php @@ -77,4 +77,4 @@ class ProductRepository extends ServiceEntityRepository return $product_ids; } -} \ No newline at end of file +} diff --git a/src/Repository/SettingsRepository.php b/src/Repository/SettingsRepository.php index eaceabf..0160973 100644 --- a/src/Repository/SettingsRepository.php +++ b/src/Repository/SettingsRepository.php @@ -39,28 +39,28 @@ class SettingsRepository extends ServiceEntityRepository } } -// /** -// * @return Settings[] Returns an array of Settings objects -// */ -// public function findByExampleField($value): array -// { -// return $this->createQueryBuilder('s') -// ->andWhere('s.exampleField = :val') -// ->setParameter('val', $value) -// ->orderBy('s.id', 'ASC') -// ->setMaxResults(10) -// ->getQuery() -// ->getResult() -// ; -// } + // /** + // * @return Settings[] Returns an array of Settings objects + // */ + // public function findByExampleField($value): array + // { + // return $this->createQueryBuilder('s') + // ->andWhere('s.exampleField = :val') + // ->setParameter('val', $value) + // ->orderBy('s.id', 'ASC') + // ->setMaxResults(10) + // ->getQuery() + // ->getResult() + // ; + // } -// public function findOneBySomeField($value): ?Settings -// { -// return $this->createQueryBuilder('s') -// ->andWhere('s.exampleField = :val') -// ->setParameter('val', $value) -// ->getQuery() -// ->getOneOrNullResult() -// ; -// } + // public function findOneBySomeField($value): ?Settings + // { + // return $this->createQueryBuilder('s') + // ->andWhere('s.exampleField = :val') + // ->setParameter('val', $value) + // ->getQuery() + // ->getOneOrNullResult() + // ; + // } } diff --git a/src/Repository/StockRepository.php b/src/Repository/StockRepository.php index c73b2d5..ac36ae1 100644 --- a/src/Repository/StockRepository.php +++ b/src/Repository/StockRepository.php @@ -75,4 +75,4 @@ class StockRepository extends ServiceEntityRepository $this->getEntityManager()->flush(); $this->batch = []; } -} \ No newline at end of file +} diff --git a/src/Repository/WarehouseRepository.php b/src/Repository/WarehouseRepository.php index 3ed59db..7d6eba9 100644 --- a/src/Repository/WarehouseRepository.php +++ b/src/Repository/WarehouseRepository.php @@ -55,13 +55,13 @@ class WarehouseRepository extends ServiceEntityRepository ->getResult(); } -// public function findOneBySomeField($value): ?Warehouse -// { -// return $this->createQueryBuilder('w') -// ->andWhere('w.exampleField = :val') -// ->setParameter('val', $value) -// ->getQuery() -// ->getOneOrNullResult() -// ; -// } -} \ No newline at end of file + // public function findOneBySomeField($value): ?Warehouse + // { + // return $this->createQueryBuilder('w') + // ->andWhere('w.exampleField = :val') + // ->setParameter('val', $value) + // ->getQuery() + // ->getOneOrNullResult() + // ; + // } +} diff --git a/src/Security/ApiKeyAuthenticator.php b/src/Security/ApiKeyAuthenticator.php index 0abc5d8..3df9c96 100644 --- a/src/Security/ApiKeyAuthenticator.php +++ b/src/Security/ApiKeyAuthenticator.php @@ -15,7 +15,6 @@ use Symfony\Component\Security\Http\Authenticator\Passport\SelfValidatingPasspor class ApiKeyAuthenticator extends AbstractAuthenticator { - /** * Called on every request to decide if this authenticator should be * used for the request. Returning `false` will cause this authenticator @@ -61,4 +60,4 @@ class ApiKeyAuthenticator extends AbstractAuthenticator return new JsonResponse($data, Response::HTTP_UNAUTHORIZED); } -} \ No newline at end of file +}