ResetPassword.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: Michele
  5. * Date: 5/3/2018
  6. * Time: 11:07 AM
  7. */
  8. namespace Amazon\Payment\Block\Widget;
  9. use Magento\Framework\View\Element\Template;
  10. use Magento\Framework\View\Element\Template\Context;
  11. use Magento\Framework\UrlFactory;
  12. use Magento\Customer\Model\Session;
  13. use Amazon\Login\Api\CustomerLinkRepositoryInterface;
  14. /**
  15. * @api
  16. */
  17. class ResetPassword extends Template
  18. {
  19. private $urlModel;
  20. private $session;
  21. private $customerLink;
  22. public function __construct(
  23. Context $context,
  24. UrlFactory $urlFactory,
  25. Session $session,
  26. CustomerLinkRepositoryInterface $customerLink,
  27. array $data = []
  28. ) {
  29. parent::__construct($context, $data);
  30. $this->urlModel = $urlFactory->create();
  31. $this->session = $session;
  32. $this->customerLink = $customerLink;
  33. }
  34. protected function _prepareLayout()
  35. {
  36. parent::_prepareLayout();
  37. if (!$this->getTemplate()) {
  38. $this->setTemplate('widget/resetpassword.phtml');
  39. }
  40. return $this;
  41. }
  42. public function displayAmazonInfo()
  43. {
  44. $id = $this->session->getCustomer()->getId();
  45. $amazon = $this->customerLink->get($id);
  46. if ($amazon && $amazon->getAmazonId()) {
  47. return true;
  48. }
  49. return false;
  50. }
  51. public function getLink()
  52. {
  53. $url = $this->urlModel->getUrl('customer/account/forgotpassword');
  54. return $url;
  55. }
  56. }