src/Service/App/Merchant/FecReport/Listener/InvoiceListener.php line 90

Open in your IDE?
  1. <?php
  2. namespace App\Service\App\Merchant\FecReport\Listener;
  3. use App\Core\BackgroundWork\Contract\IClient;
  4. use App\Core\MerchantSelector\Contract\IMerchantSelector;
  5. use App\Service\App\Merchant\CustomFeature\Implementation\FecReportCustomFeature;
  6. use App\Service\App\Merchant\Invoice\Event\FinalizeInvoiceEvent;
  7. use App\Service\App\Merchant\Invoice\Event\PaidInvoiceEvent;
  8. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  9. /**
  10.  * @deprecated FEC entry creation is now synchronous and atomic with the invoice
  11.  * lifecycle (see FinalizeInvoiceService / PayInvoiceService, which call
  12.  * IAddFecEntryService directly inside their transaction). This listener no longer
  13.  * dispatches the async Gearman job; it is kept as a no-op for one release while
  14.  * any in-flight queued jobs drain, then will be removed together with
  15.  * AddFecEntryWorker/Handler/Data.
  16.  */
  17. class InvoiceListener implements EventSubscriberInterface
  18. {
  19.     /**
  20.      * Client
  21.      *
  22.      * @var IClient
  23.      */
  24.     private IClient $client;
  25.     /**
  26.      * Merchant selector
  27.      *
  28.      * @var IMerchantSelector
  29.      */
  30.     private IMerchantSelector $merchantSelector;
  31.     /**
  32.      * FEC report custom feature
  33.      *
  34.      * @var FecReportCustomFeature
  35.      */
  36.     private FecReportCustomFeature $fecReportCustomFeature;
  37.     /**
  38.      * Constructor
  39.      *
  40.      * @param IClient $client
  41.      * @param IMerchantSelector $merchantSelector
  42.      * @param FecReportCustomFeature $fecReportCustomFeature
  43.      */
  44.     public function __construct(
  45.         IClient $client,
  46.         IMerchantSelector $merchantSelector,
  47.         FecReportCustomFeature $fecReportCustomFeature
  48.     )
  49.     {
  50.         $this->client = $client;
  51.         $this->merchantSelector = $merchantSelector;
  52.         $this->fecReportCustomFeature = $fecReportCustomFeature;
  53.     }
  54.     /**
  55.      * Returns an array of event names this subscriber wants to listen to.
  56.      *
  57.      * The array keys are event names and the value can be:
  58.      *
  59.      *  * The method name to call (priority defaults to 0)
  60.      *  * An array composed of the method name to call and the priority
  61.      *  * An array of arrays composed of the method names to call and respective
  62.      *    priorities, or 0 if unset
  63.      *
  64.      * For instance:
  65.      *
  66.      *  * ['eventName' => 'methodName']
  67.      *  * ['eventName' => ['methodName', $priority]]
  68.      *  * ['eventName' => [['methodName1', $priority], ['methodName2']]]
  69.      *
  70.      * The code must not depend on runtime state as it will only be called at compile time.
  71.      * All logic depending on runtime state must be put into the individual methods handling the events.
  72.      *
  73.      * @return array<string, string|array{0: string, 1: int}|list<array{0: string, 1?: int}>>
  74.      */
  75.     public static function getSubscribedEvents()
  76.     {
  77.         return [
  78.             FinalizeInvoiceEvent::NAME => 'onFinalizeInvoice',
  79.             PaidInvoiceEvent::NAME => 'onPaidInvoice',
  80.         ];
  81.     }
  82.     /**
  83.      * On finalize invoice
  84.      *
  85.      * @param FinalizeInvoiceEvent $event
  86.      * @return void
  87.      */
  88.     public function onFinalizeInvoice(FinalizeInvoiceEvent $event): void
  89.     {
  90.         // No-op: FEC entries are created synchronously inside FinalizeInvoiceService.
  91.     }
  92.     /**
  93.      * On paid invoice event
  94.      *
  95.      * @param PaidInvoiceEvent $event
  96.      * @return void
  97.      */
  98.     public function onPaidInvoice(PaidInvoiceEvent $event): void
  99.     {
  100.         // No-op: FEC entries are created synchronously inside PayInvoiceService / FinalizeInvoiceService.
  101.     }
  102. }