Manage.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Newsletter\Controller;
  7. use Magento\Framework\App\RequestInterface;
  8. /**
  9. * Customers newsletter subscription controller
  10. */
  11. abstract class Manage extends \Magento\Framework\App\Action\Action
  12. {
  13. /**
  14. * Customer session
  15. *
  16. * @var \Magento\Customer\Model\Session
  17. */
  18. protected $_customerSession;
  19. /**
  20. * @param \Magento\Framework\App\Action\Context $context
  21. * @param \Magento\Customer\Model\Session $customerSession
  22. */
  23. public function __construct(
  24. \Magento\Framework\App\Action\Context $context,
  25. \Magento\Customer\Model\Session $customerSession
  26. ) {
  27. parent::__construct($context);
  28. $this->_customerSession = $customerSession;
  29. }
  30. /**
  31. * Check customer authentication for some actions
  32. *
  33. * @param RequestInterface $request
  34. * @return \Magento\Framework\App\ResponseInterface
  35. */
  36. public function dispatch(RequestInterface $request)
  37. {
  38. if (!$this->_customerSession->authenticate()) {
  39. $this->_actionFlag->set('', 'no-dispatch', true);
  40. }
  41. return parent::dispatch($request);
  42. }
  43. }