![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/vendor/magento/module-checkout/Block/ |
<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ namespace Magento\Checkout\Block; use Magento\Framework\View\Element\Template; /** * @api * @since 100.0.2 */ class Registration extends \Magento\Framework\View\Element\Template { /** * @var \Magento\Checkout\Model\Session */ protected $checkoutSession; /** * @var \Magento\Customer\Model\Session */ protected $customerSession; /** * @var \Magento\Customer\Model\Registration */ protected $registration; /** * @var \Magento\Customer\Api\AccountManagementInterface */ protected $accountManagement; /** * @var \Magento\Sales\Api\OrderRepositoryInterface */ protected $orderRepository; /** * @var \Magento\Sales\Model\Order\Address\Validator */ protected $addressValidator; /** * @param Template\Context $context * @param \Magento\Checkout\Model\Session $checkoutSession * @param \Magento\Customer\Model\Session $customerSession * @param \Magento\Customer\Model\Registration $registration * @param \Magento\Customer\Api\AccountManagementInterface $accountManagement * @param \Magento\Sales\Api\OrderRepositoryInterface $orderRepository * @param \Magento\Sales\Model\Order\Address\Validator $addressValidator * @param array $data * @codeCoverageIgnore */ public function __construct( Template\Context $context, \Magento\Checkout\Model\Session $checkoutSession, \Magento\Customer\Model\Session $customerSession, \Magento\Customer\Model\Registration $registration, \Magento\Customer\Api\AccountManagementInterface $accountManagement, \Magento\Sales\Api\OrderRepositoryInterface $orderRepository, \Magento\Sales\Model\Order\Address\Validator $addressValidator, array $data = [] ) { $this->checkoutSession = $checkoutSession; $this->customerSession = $customerSession; $this->registration = $registration; $this->accountManagement = $accountManagement; $this->orderRepository = $orderRepository; $this->addressValidator = $addressValidator; parent::__construct($context, $data); } /** * Retrieve current email address * * @return string * @codeCoverageIgnore */ public function getEmailAddress() { return $this->checkoutSession->getLastRealOrder()->getCustomerEmail(); } /** * Retrieve account creation url * * @return string * @codeCoverageIgnore */ public function getCreateAccountUrl() { return $this->getUrl('checkout/account/delegateCreate'); } /** * {@inheritdoc} */ public function toHtml() { if ($this->customerSession->isLoggedIn() || !$this->registration->isAllowed() || !$this->accountManagement->isEmailAvailable($this->getEmailAddress()) || !$this->validateAddresses() ) { return ''; } return parent::toHtml(); } /** * Validate order addresses * * @return bool */ protected function validateAddresses() { $order = $this->orderRepository->get($this->checkoutSession->getLastOrderId()); $addresses = $order->getAddresses(); foreach ($addresses as $address) { $result = $this->addressValidator->validateForCustomer($address); if (is_array($result) && !empty($result)) { return false; } } return true; } }