src/InsuranceCompany/OZK/SOAP/Subscriber/XmlReplaceSubscriber.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\InsuranceCompany\OZK\SOAP\Subscriber;
  3. use App\SoapClient\Event\RequestEvent;
  4. use Soap\Engine\HttpBinding\SoapRequest;
  5. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  6. class XmlReplaceSubscriber implements EventSubscriberInterface
  7. {
  8.     public function onRequest(RequestEvent $event): void
  9.     {
  10.         $request $event->getRequest();
  11.         if ($event->getMethod() === 'policySaveSmetka') {
  12.             $event->setRequest(new SoapRequest(
  13.                 str_replace(
  14.                     [
  15.                         ' xsi:type="ns1:stikeri"',
  16.                         ' xsi:type="ns1:sertifikati"',
  17.                     ],
  18.                     '',
  19.                     $request->getRequest()
  20.                 ),
  21.                 $request->getLocation(),
  22.                 $request->getAction(),
  23.                 $request->getVersion(),
  24.                 $request->getOneWay()
  25.             ));
  26.         }
  27.     }
  28.     /**
  29.      * @inheritDoc
  30.      * @noinspection PhpArrayShapeAttributeCanBeAddedInspection
  31.      */
  32.     public static function getSubscribedEvents(): array
  33.     {
  34.         return [
  35.             RequestEvent::class => 'onRequest',
  36.         ];
  37.     }
  38. }