Info.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Customer\Block\Form\Login;
  7. /**
  8. * Customer login info block
  9. *
  10. * @api
  11. * @since 100.0.2
  12. */
  13. class Info extends \Magento\Framework\View\Element\Template
  14. {
  15. /**
  16. * @var \Magento\Customer\Model\Url
  17. */
  18. protected $_customerUrl;
  19. /**
  20. * Checkout data
  21. *
  22. * @var \Magento\Checkout\Helper\Data
  23. */
  24. protected $checkoutData;
  25. /**
  26. * Core url
  27. *
  28. * @var \Magento\Framework\Url\Helper\Data
  29. */
  30. protected $coreUrl;
  31. /**
  32. * Registration
  33. *
  34. * @var \Magento\Customer\Model\Registration
  35. */
  36. protected $registration;
  37. /**
  38. * @param \Magento\Framework\View\Element\Template\Context $context
  39. * @param \Magento\Customer\Model\Registration $registration
  40. * @param \Magento\Customer\Model\Url $customerUrl
  41. * @param \Magento\Checkout\Helper\Data $checkoutData
  42. * @param \Magento\Framework\Url\Helper\Data $coreUrl
  43. * @param array $data
  44. */
  45. public function __construct(
  46. \Magento\Framework\View\Element\Template\Context $context,
  47. \Magento\Customer\Model\Registration $registration,
  48. \Magento\Customer\Model\Url $customerUrl,
  49. \Magento\Checkout\Helper\Data $checkoutData,
  50. \Magento\Framework\Url\Helper\Data $coreUrl,
  51. array $data = []
  52. ) {
  53. parent::__construct($context, $data);
  54. $this->registration = $registration;
  55. $this->_customerUrl = $customerUrl;
  56. $this->checkoutData = $checkoutData;
  57. $this->coreUrl = $coreUrl;
  58. }
  59. /**
  60. * Return registration
  61. *
  62. * @return \Magento\Customer\Model\Registration
  63. */
  64. public function getRegistration()
  65. {
  66. return $this->registration;
  67. }
  68. /**
  69. * Retrieve create new account url
  70. *
  71. * @return string
  72. */
  73. public function getCreateAccountUrl()
  74. {
  75. $url = $this->getData('create_account_url');
  76. if ($url === null) {
  77. $url = $this->_customerUrl->getRegisterUrl();
  78. }
  79. if ($this->checkoutData->isContextCheckout()) {
  80. $url = $this->coreUrl->addRequestParam($url, ['context' => 'checkout']);
  81. }
  82. return $url;
  83. }
  84. }