diff --git a/src/Model/Resolver/ShareWishlist.php b/src/Model/Resolver/ShareWishlist.php index c0c38de..f776899 100644 --- a/src/Model/Resolver/ShareWishlist.php +++ b/src/Model/Resolver/ShareWishlist.php @@ -29,6 +29,7 @@ use Magento\Store\Model\StoreManagerInterface; use Magento\Wishlist\Model\WishlistFactory; use ScandiPWA\WishlistGraphQl\Model\Resolver\WishlistResolver; +use Laminas\Validator\EmailAddress; class ShareWishlist implements ResolverInterface { @@ -69,6 +70,12 @@ class ShareWishlist implements ResolverInterface */ protected $layoutFactory; + /** + * @var EmailAddress + */ + protected $emailValidator; + + /** * @param Escaper $escaper * @param UrlInterface $url @@ -79,6 +86,7 @@ class ShareWishlist implements ResolverInterface * @param TransportBuilder $transportBuilder * @param StoreManagerInterface $storeManager * @param CustomerRepository $customerRepository + * @param EmailAddress $emailAddress */ public function __construct( Escaper $escaper, @@ -89,7 +97,8 @@ public function __construct( WishlistResolver $wishlistResolver, TransportBuilder $transportBuilder, StoreManagerInterface $storeManager, - CustomerRepository $customerRepository + CustomerRepository $customerRepository, + EmailAddress $emailValidator ) { $this->url = $url; $this->escaper = $escaper; @@ -100,6 +109,7 @@ public function __construct( $this->wishlistResolver = $wishlistResolver; $this->transportBuilder = $transportBuilder; $this->customerRepository = $customerRepository; + $this->emailValidator = $emailValidator; } /** @@ -145,7 +155,7 @@ public function resolve( continue; } - if (!\Zend_Validate::is($email, \Magento\Framework\Validator\EmailAddress::class)) { + if (!$this->emailValidator->isValid($email)) { throw new GraphQlInputException(__('Provided emails are not valid')); }