Hey Everyonem, currently i’m trying to call a PUT Method inside a only allowed POST Controller. My plugin is just a Subscriber wich is attached to the Order Placement Event. From there i’m trying to call a Service with API PUT method to send my articles to an External System.
<?php
namespace Swag\RestApiHandling\Subscriber;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepositoryInterface;
use Shopware\Core\Checkout\Cart\CartEvents;
use \Shopware\Core\Checkout\Cart\Event\CheckoutOrderPlacedEvent;
use Zend\EventManager\Exception\RuntimeException;
use Swag\RestApiHandling\Service\R2OService;
class CartEventSubscriber implements EventSubscriberInterface{
/**
* @var EntityRepositoryInterface
*/
private $orderRepository;
/**
* @var R2OService
*/
private $r2oService;
public function __construct(EntityRepositoryInterface $orderRepository,R2OService $r2oService){
$this->orderRepository = $orderRepository;
$this->r2oService = $r2oService;
}
public static function getSubscribedEvents(){
return [
CheckoutOrderPlacedEvent::class => [ 'cartSubmit', 1000],
];
}
/**
*@Route("/checkout/order", methods={"PUT","HEAD"}) (Just a test, can be ignored)
*/
public function cartSubmit(CheckoutOrderPlacedEvent $orderPlacedEvent): JsonResponse{
//$this->r2oService->put("dailyReport/open",[]);
$this->r2oService->put("document/invoice/",[ stuff] $this->r2oService->put("/dailyReport/close",[]);
return new JsonResponse("done");
}
}
If there is no way, do you know a workaround? Any help is apreciated
Kind regards