Index.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Contact\Controller;
  7. use Magento\Contact\Model\ConfigInterface;
  8. use Magento\Framework\App\Action\Context;
  9. use Magento\Framework\App\RequestInterface;
  10. use Magento\Framework\Exception\NotFoundException;
  11. /**
  12. * Contact module base controller
  13. */
  14. abstract class Index extends \Magento\Framework\App\Action\Action
  15. {
  16. /**
  17. * Recipient email config path
  18. */
  19. const XML_PATH_EMAIL_RECIPIENT = ConfigInterface::XML_PATH_EMAIL_RECIPIENT;
  20. /**
  21. * Sender email config path
  22. */
  23. const XML_PATH_EMAIL_SENDER = ConfigInterface::XML_PATH_EMAIL_SENDER;
  24. /**
  25. * Email template config path
  26. */
  27. const XML_PATH_EMAIL_TEMPLATE = ConfigInterface::XML_PATH_EMAIL_TEMPLATE;
  28. /**
  29. * Enabled config path
  30. */
  31. const XML_PATH_ENABLED = ConfigInterface::XML_PATH_ENABLED;
  32. /**
  33. * @var ConfigInterface
  34. */
  35. private $contactsConfig;
  36. /**
  37. * @param Context $context
  38. * @param ConfigInterface $contactsConfig
  39. */
  40. public function __construct(
  41. Context $context,
  42. ConfigInterface $contactsConfig
  43. ) {
  44. parent::__construct($context);
  45. $this->contactsConfig = $contactsConfig;
  46. }
  47. /**
  48. * Dispatch request
  49. *
  50. * @param RequestInterface $request
  51. * @return \Magento\Framework\App\ResponseInterface
  52. * @throws \Magento\Framework\Exception\NotFoundException
  53. */
  54. public function dispatch(RequestInterface $request)
  55. {
  56. if (!$this->contactsConfig->isEnabled()) {
  57. throw new NotFoundException(__('Page not found.'));
  58. }
  59. return parent::dispatch($request);
  60. }
  61. }