diff --git a/Observer/CustomerRegisterSuccess.php b/Observer/CustomerRegisterSuccess.php index 0348a81acbfa125b5d5ba698ebfba54421ac509e..970f821a340ff24c8049f8952e8baa22e964b218 100644 --- a/Observer/CustomerRegisterSuccess.php +++ b/Observer/CustomerRegisterSuccess.php @@ -4,6 +4,10 @@ namespace NicolasBejean\Customer\Observer; use Magento\Framework\Event\Observer; use Magento\Framework\Event\ObserverInterface; +use Magento\Customer\Api\Data\CustomerInterface; + +use NicolasBejean\Customer\Helper\SendCustomer; + /** * Class CustomerRegisterSuccess * @@ -16,11 +20,18 @@ use Magento\Framework\Event\ObserverInterface; class CustomerRegisterSuccess implements ObserverInterface { /** - * CustomerRegisterSuccess constructor. + * @var SendCustomer */ - public function __construct() - { + protected $sendCustomer; + /** + * CustomerRegisterSuccess constructor. + * @param SendCustomer $sendCustomer + */ + public function __construct( + SendCustomer $sendCustomer + ) { + $this->sendCustomer = $sendCustomer; } /** @@ -30,6 +41,15 @@ class CustomerRegisterSuccess implements ObserverInterface */ public function execute(Observer $observer) { - // TODO: Implement execute() method. + /* Récupère l'événement */ + $event = $observer->getEvent(); + + /* Vérifie si le nom de l'événement est bien celui souhaité */ + if ($event->getName() === 'customer_register_success') { + /** @var CustomerInterface $customer */ + $customer = $observer->getData('customer'); + + $this->sendCustomer->execute('frontend', $customer); + } } }