Slack notify
This commit is contained in:
82
src/Command/JtlExportCommand.php
Normal file
82
src/Command/JtlExportCommand.php
Normal file
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
namespace App\Command;
|
||||
|
||||
use App\Helper\HiltesImport;
|
||||
use App\Helper\Jtl;
|
||||
use App\Repository\ProductRepository;
|
||||
use App\Repository\StockRepository;
|
||||
use App\Repository\WarehouseRepository;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\Console\Attribute\AsCommand;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
|
||||
#[AsCommand(
|
||||
name: 'jtl:export',
|
||||
description: 'Create a export file for JTL Ameise',
|
||||
)]
|
||||
class JtlExportCommand extends Command
|
||||
{
|
||||
private $stockRepository;
|
||||
private $warehouseRepository;
|
||||
private $productRepository;
|
||||
private $logger;
|
||||
public function __construct(
|
||||
ProductRepository $productRepository,
|
||||
StockRepository $stockRepository,
|
||||
WarehouseRepository $warehouseRepository,
|
||||
LoggerInterface $logger
|
||||
)
|
||||
{
|
||||
$this->productRepository = $productRepository;
|
||||
$this->stockRepository = $stockRepository;
|
||||
$this->warehouseRepository = $warehouseRepository;
|
||||
$this->logger = $logger;
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
protected function configure(): void
|
||||
{
|
||||
$this
|
||||
->addArgument('arg1', InputArgument::OPTIONAL, 'Argument description')
|
||||
->addOption('option1', null, InputOption::VALUE_NONE, 'Option description')
|
||||
;
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output): int
|
||||
{
|
||||
$io = new SymfonyStyle($input, $output);
|
||||
// $arg1 = $input->getArgument('arg1');
|
||||
//
|
||||
// if ($arg1) {
|
||||
// $io->note(sprintf('You passed an argument: %s', $arg1));
|
||||
// }
|
||||
//
|
||||
// if ($input->getOption('option1')) {
|
||||
// // ...
|
||||
// }
|
||||
|
||||
$io = new SymfonyStyle($input, $output);
|
||||
|
||||
$io->success('Start JTL Export');
|
||||
|
||||
/**
|
||||
* @var HiltesImport
|
||||
*/
|
||||
$jtl = new Jtl($this->productRepository,$this->warehouseRepository,$this->stockRepository,$this->logger);
|
||||
|
||||
$data = $jtl->getProducts();
|
||||
$jtl->createExportFile($data);
|
||||
|
||||
|
||||
|
||||
$io->success('Ende JTL Export');
|
||||
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
}
|
||||
60
src/Command/JtlImportCommand.php
Normal file
60
src/Command/JtlImportCommand.php
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace App\Command;
|
||||
|
||||
use Symfony\Component\Console\Attribute\AsCommand;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
use Symfony\Component\Notifier\Chatter;
|
||||
use Symfony\Component\Notifier\Message\ChatMessage;
|
||||
use Symfony\Component\Notifier\ChatterInterface;
|
||||
use Symfony\Component\Notifier\Transport;
|
||||
|
||||
#[AsCommand(
|
||||
name: 'jtl:import',
|
||||
description: 'Add a short description for your command',
|
||||
)]
|
||||
class JtlImportCommand extends Command
|
||||
{
|
||||
protected function configure(): void
|
||||
{
|
||||
$this
|
||||
->addArgument('arg1', InputArgument::OPTIONAL, 'Argument description')
|
||||
->addOption('option1', null, InputOption::VALUE_NONE, 'Option description')
|
||||
;
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output): int
|
||||
{
|
||||
$io = new SymfonyStyle($input, $output);
|
||||
$arg1 = $input->getArgument('arg1');
|
||||
|
||||
if ($arg1) {
|
||||
$io->note(sprintf('You passed an argument: %s', $arg1));
|
||||
}
|
||||
|
||||
if ($input->getOption('option1')) {
|
||||
// ...
|
||||
}
|
||||
|
||||
$chatter = new Chatter(new Transport('xoxb-1234-56789abcdefghijklmnopqrstuv'));
|
||||
|
||||
|
||||
$message = (new ChatMessage('You got a new invoice for 15 EUR.'))
|
||||
// if not set explicitly, the message is sent to the
|
||||
// default transport (the first one configured)
|
||||
->transport('slack');
|
||||
|
||||
|
||||
|
||||
$sentMessage = $chatter->send($message);
|
||||
|
||||
$io->success('You have a new command! Now make it your own! Pass --help to see your options.');
|
||||
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@
|
||||
namespace App\Command;
|
||||
|
||||
use App\Controller\ShopwareController;
|
||||
use App\Entity\Orders;
|
||||
use App\Entity\Order;
|
||||
use App\Helper\Shopware;
|
||||
use App\Repository\OrdersRepository;
|
||||
|
||||
@@ -32,17 +32,17 @@ use Vin\ShopwareSdk\Factory\RepositoryFactory;
|
||||
)]
|
||||
class SwGetOrdersCommand extends Command
|
||||
{
|
||||
private $ordersRepository;
|
||||
private $orderRepository;
|
||||
private $logger;
|
||||
private $sw;
|
||||
private $orderData;
|
||||
|
||||
|
||||
public function __construct(OrdersRepository $ordersRepository, LoggerInterface $logger)
|
||||
public function __construct(OrdersRepository $orderRepository, LoggerInterface $logger)
|
||||
{
|
||||
$this->ordersRepository = $ordersRepository;
|
||||
$this->orderRepository = $orderRepository;
|
||||
$this->logger = $logger;
|
||||
$this->sw = new Shopware();
|
||||
$this->sw = new Shopware($logger);
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
@@ -82,7 +82,7 @@ class SwGetOrdersCommand extends Command
|
||||
*/
|
||||
private function getOrders():array
|
||||
{
|
||||
return $this->ordersRepository->findAll();
|
||||
return $this->orderRepository->findAll();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -121,4 +121,4 @@ class SwGetOrdersCommand extends Command
|
||||
$orderData->setStatus = 1;
|
||||
$this->ordersRepository->add($orderData, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user