123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142 |
- <?php
- /**
- * Copyright © Magento, Inc. All rights reserved.
- * See COPYING.txt for license details.
- */
- namespace Magento\Customer\Controller;
- use Magento\Framework\App\RequestInterface;
- /**
- * Customer address controller
- *
- * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
- */
- abstract class Address extends \Magento\Framework\App\Action\Action
- {
- /**
- * @var \Magento\Customer\Model\Session
- */
- protected $_customerSession;
- /**
- * @var \Magento\Framework\Data\Form\FormKey\Validator
- */
- protected $_formKeyValidator;
- /**
- * @var \Magento\Customer\Api\AddressRepositoryInterface
- */
- protected $_addressRepository;
- /**
- * @var \Magento\Customer\Model\Metadata\FormFactory
- */
- protected $_formFactory;
- /**
- * @var \Magento\Customer\Api\Data\AddressInterfaceFactory
- */
- protected $addressDataFactory;
- /**
- * @var \Magento\Customer\Api\Data\RegionInterfaceFactory
- */
- protected $regionDataFactory;
- /**
- * @var \Magento\Framework\Reflection\DataObjectProcessor
- */
- protected $_dataProcessor;
- /**
- * @var \Magento\Framework\Api\DataObjectHelper
- */
- protected $dataObjectHelper;
- /**
- * @var \Magento\Framework\Controller\Result\ForwardFactory
- */
- protected $resultForwardFactory;
- /**
- * @var \Magento\Framework\View\Result\PageFactory
- */
- protected $resultPageFactory;
- /**
- * @param \Magento\Framework\App\Action\Context $context
- * @param \Magento\Customer\Model\Session $customerSession
- * @param \Magento\Framework\Data\Form\FormKey\Validator $formKeyValidator
- * @param \Magento\Customer\Model\Metadata\FormFactory $formFactory
- * @param \Magento\Customer\Api\AddressRepositoryInterface $addressRepository
- * @param \Magento\Customer\Api\Data\AddressInterfaceFactory $addressDataFactory
- * @param \Magento\Customer\Api\Data\RegionInterfaceFactory $regionDataFactory
- * @param \Magento\Framework\Reflection\DataObjectProcessor $dataProcessor
- * @param \Magento\Framework\Api\DataObjectHelper $dataObjectHelper
- * @param \Magento\Framework\Controller\Result\ForwardFactory $resultForwardFactory
- * @param \Magento\Framework\View\Result\PageFactory $resultPageFactory
- * @SuppressWarnings(PHPMD.ExcessiveParameterList)
- */
- public function __construct(
- \Magento\Framework\App\Action\Context $context,
- \Magento\Customer\Model\Session $customerSession,
- \Magento\Framework\Data\Form\FormKey\Validator $formKeyValidator,
- \Magento\Customer\Model\Metadata\FormFactory $formFactory,
- \Magento\Customer\Api\AddressRepositoryInterface $addressRepository,
- \Magento\Customer\Api\Data\AddressInterfaceFactory $addressDataFactory,
- \Magento\Customer\Api\Data\RegionInterfaceFactory $regionDataFactory,
- \Magento\Framework\Reflection\DataObjectProcessor $dataProcessor,
- \Magento\Framework\Api\DataObjectHelper $dataObjectHelper,
- \Magento\Framework\Controller\Result\ForwardFactory $resultForwardFactory,
- \Magento\Framework\View\Result\PageFactory $resultPageFactory
- ) {
- $this->_customerSession = $customerSession;
- $this->_formKeyValidator = $formKeyValidator;
- $this->_formFactory = $formFactory;
- $this->_addressRepository = $addressRepository;
- $this->addressDataFactory = $addressDataFactory;
- $this->regionDataFactory = $regionDataFactory;
- $this->_dataProcessor = $dataProcessor;
- $this->dataObjectHelper = $dataObjectHelper;
- $this->resultForwardFactory = $resultForwardFactory;
- $this->resultPageFactory = $resultPageFactory;
- parent::__construct($context);
- }
- /**
- * Retrieve customer session object
- *
- * @return \Magento\Customer\Model\Session
- */
- protected function _getSession()
- {
- return $this->_customerSession;
- }
- /**
- * Check customer authentication
- *
- * @param RequestInterface $request
- * @return \Magento\Framework\App\ResponseInterface
- */
- public function dispatch(RequestInterface $request)
- {
- if (!$this->_getSession()->authenticate()) {
- $this->_actionFlag->set('', 'no-dispatch', true);
- }
- return parent::dispatch($request);
- }
- /**
- * @param string $route
- * @param array $params
- * @return string
- */
- protected function _buildUrl($route = '', $params = [])
- {
- /** @var \Magento\Framework\UrlInterface $urlBuilder */
- $urlBuilder = $this->_objectManager->create(\Magento\Framework\UrlInterface::class);
- return $urlBuilder->getUrl($route, $params);
- }
- }
|