Create.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. /**
  3. *
  4. * Copyright © Magento, Inc. All rights reserved.
  5. * See COPYING.txt for license details.
  6. */
  7. namespace Magento\Customer\Controller\Account;
  8. use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
  9. use Magento\Customer\Model\Registration;
  10. use Magento\Customer\Model\Session;
  11. use Magento\Framework\View\Result\PageFactory;
  12. use Magento\Framework\App\Action\Context;
  13. class Create extends \Magento\Customer\Controller\AbstractAccount implements HttpGetActionInterface
  14. {
  15. /**
  16. * @var \Magento\Customer\Model\Registration
  17. */
  18. protected $registration;
  19. /**
  20. * @var Session
  21. */
  22. protected $session;
  23. /**
  24. * @var PageFactory
  25. */
  26. protected $resultPageFactory;
  27. /**
  28. * @param Context $context
  29. * @param Session $customerSession
  30. * @param PageFactory $resultPageFactory
  31. * @param Registration $registration
  32. */
  33. public function __construct(
  34. Context $context,
  35. Session $customerSession,
  36. PageFactory $resultPageFactory,
  37. Registration $registration
  38. ) {
  39. $this->session = $customerSession;
  40. $this->resultPageFactory = $resultPageFactory;
  41. $this->registration = $registration;
  42. parent::__construct($context);
  43. }
  44. /**
  45. * Customer register form page
  46. *
  47. * @return \Magento\Framework\Controller\Result\Redirect|\Magento\Framework\View\Result\Page
  48. */
  49. public function execute()
  50. {
  51. if ($this->session->isLoggedIn() || !$this->registration->isAllowed()) {
  52. /** @var \Magento\Framework\Controller\Result\Redirect $resultRedirect */
  53. $resultRedirect = $this->resultRedirectFactory->create();
  54. $resultRedirect->setPath('*/*');
  55. return $resultRedirect;
  56. }
  57. /** @var \Magento\Framework\View\Result\Page $resultPage */
  58. $resultPage = $this->resultPageFactory->create();
  59. return $resultPage;
  60. }
  61. }