src/Salesforce/EventListener/SalesForceReviewListener.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Salesforce\EventListener;
  3. use App\Entity\ProUser;
  4. use App\Event\EntityEvent;
  5. use App\Salesforce\Api\ClientInterface;
  6. class SalesForceReviewListener
  7. {
  8.     public function __construct(private readonly ClientInterface $client)
  9.     {
  10.     }
  11.     public function onNewReview(EntityEvent $event): void
  12.     {
  13.         $review $event->getEntity();
  14.         $user $review->getUser();
  15.         if (null !== $user->getSfAccountId()) {
  16.             $sUser = (object) [
  17.                 'Id' => $user->getSfAccountId(),
  18.                 'Avis_client__c' => $review->getComment(),
  19.                 'Note_client__c' => $review->getNote(),
  20.             ];
  21.             $this->client->initiate();
  22.             $data $this->client->upsert('Id'$sUser'Account');
  23.             $this->client->log('upsert'$data$user instanceof ProUser 'Pro' 'User');
  24.         }
  25.     }
  26. }