local/modules/PayPal/EventListeners/PayPalCustomerListener.php line 61

  1. <?php
  2. /*************************************************************************************/
  3. /*                                                                                   */
  4. /*      Thelia                                                                         */
  5. /*                                                                                   */
  6. /*      Copyright (c) OpenStudio                                                     */
  7. /*      email : info@thelia.net                                                      */
  8. /*      web : http://www.thelia.net                                                  */
  9. /*                                                                                   */
  10. /*      This program is free software; you can redistribute it and/or modify         */
  11. /*      it under the terms of the GNU General Public License as published by         */
  12. /*      the Free Software Foundation; either version 3 of the License                */
  13. /*                                                                                   */
  14. /*      This program is distributed in the hope that it will be useful,              */
  15. /*      but WITHOUT ANY WARRANTY; without even the implied warranty of               */
  16. /*      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                */
  17. /*      GNU General Public License for more details.                                 */
  18. /*                                                                                   */
  19. /*      You should have received a copy of the GNU General Public License            */
  20. /*        along with this program. If not, see <http://www.gnu.org/licenses/>.         */
  21. /*                                                                                   */
  22. /*************************************************************************************/
  23. namespace PayPal\EventListeners;
  24. use PayPal\Event\PayPalCustomerEvent;
  25. use PayPal\Event\PayPalEvents;
  26. use Symfony\Component\EventDispatcher\EventDispatcher;
  27. use Symfony\Component\EventDispatcher\EventDispatcherInterface;
  28. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  29. use Symfony\Component\HttpFoundation\RequestStack;
  30. /**
  31.  * Class PayPalCustomerListener
  32.  * @package PayPal\EventListeners
  33.  */
  34. class PayPalCustomerListener implements EventSubscriberInterface
  35. {
  36.     /** @var RequestStack */
  37.     protected $requestStack;
  38.     /** @var EventDispatcher */
  39.     protected $dispatcher;
  40.     /**
  41.      * PayPalCustomerListener constructor.
  42.      * @param RequestStack $requestStack
  43.      * @param EventDispatcher $dispatcher
  44.      */
  45.     public function __construct(RequestStack $requestStackEventDispatcherInterface $dispatcher)
  46.     {
  47.         $this->requestStack $requestStack;
  48.         $this->dispatcher $dispatcher;
  49.     }
  50.     /**
  51.      * @param PayPalCustomerEvent $event
  52.      * @throws \Exception
  53.      * @throws \Propel\Runtime\Exception\PropelException
  54.      */
  55.     public function createOrUpdate(PayPalCustomerEvent $event)
  56.     {
  57.         $event->getPayPalCustomer()->save();
  58.     }
  59.     /**
  60.      * @param PayPalCustomerEvent $event
  61.      * @throws \Exception
  62.      * @throws \Propel\Runtime\Exception\PropelException
  63.      */
  64.     public function delete(PayPalCustomerEvent $event)
  65.     {
  66.         $event->getPayPalCustomer()->delete();
  67.     }
  68.     /**
  69.      * @return array The event names to listen to
  70.      */
  71.     public static function getSubscribedEvents()
  72.     {
  73.         return [
  74.             PayPalEvents::PAYPAL_CUSTOMER_CREATE => ['createOrUpdate'128],
  75.             PayPalEvents::PAYPAL_CUSTOMER_UPDATE => ['createOrUpdate'128],
  76.             PayPalEvents::PAYPAL_CUSTOMER_DELETE => ['delete'128]
  77.         ];
  78.     }
  79. }