local/modules/WireTransfer/Listener/SendPaymentConfirmationEmail.php line 71

  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 WireTransfer\Listener;
  24. use WireTransfer\WireTransfer;
  25. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  26. use Thelia\Action\BaseAction;
  27. use Thelia\Core\Event\Order\OrderEvent;
  28. use Thelia\Core\Event\TheliaEvents;
  29. use Thelia\Mailer\MailerFactory;
  30. use Thelia\Core\Template\ParserInterface;
  31. use Thelia\Model\ConfigQuery;
  32. use Thelia\Model\MessageQuery;
  33. /**
  34.  * Class SendEMail
  35.  * @package IciRelais\Listener
  36.  * @author Thelia <info@thelia.net>
  37.  */
  38. class SendPaymentConfirmationEmail extends BaseAction implements EventSubscriberInterface
  39. {
  40.     /**
  41.      * @var MailerFactory
  42.      */
  43.     protected $mailer;
  44.     /**
  45.      * @var ParserInterface
  46.      */
  47.     protected $parser;
  48.     public function __construct(ParserInterface $parser,MailerFactory $mailer)
  49.     {
  50.         $this->parser $parser;
  51.         $this->mailer $mailer;
  52.     }
  53.     /**
  54.      * @return \Thelia\Mailer\MailerFactory
  55.      */
  56.     public function getMailer()
  57.     {
  58.         return $this->mailer;
  59.     }
  60.     /*
  61.      * @params OrderEvent $order
  62.      *
  63.      * Checks if order delivery module is icirelais and if order new status is sent, send an email to the customer.
  64.      */
  65.     public function sendConfirmationEmail(OrderEvent $event)
  66.     {
  67.         if ($event->getOrder()->getPaymentModuleId() === WireTransfer::getModuleId()) {
  68.             if ($event->getOrder()->isPaid()) {
  69.                 $contact_email ConfigQuery::getStoreEmail();
  70.                 if ($contact_email) {
  71.                     $order $event->getOrder();
  72.                     $customer $order->getCustomer();
  73.                     $this->getMailer()->sendEmailToCustomer(
  74.                         'order_confirmation_wiretransfer',
  75.                         $customer,
  76.                         [
  77.                             'order_id' => $order->getId(),
  78.                             'order_ref'=> $order->getRef()
  79.                         ]
  80.                     );
  81.                 }
  82.             }
  83.         }
  84.     }
  85.     /**
  86.      * @inheritdoc
  87.      */
  88.     public static function getSubscribedEvents()
  89.     {
  90.         return array(
  91.             TheliaEvents::ORDER_UPDATE_STATUS => array("sendConfirmationEmail"128)
  92.         );
  93.     }
  94. }