Quote.php 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\SalesRule\Controller\Adminhtml\Promo;
  7. abstract class Quote extends \Magento\Backend\App\Action
  8. {
  9. /**
  10. * Authorization level of a basic admin session
  11. *
  12. * @see _isAllowed()
  13. */
  14. const ADMIN_RESOURCE = 'Magento_SalesRule::quote';
  15. /**
  16. * Core registry
  17. *
  18. * @var \Magento\Framework\Registry
  19. */
  20. protected $_coreRegistry = null;
  21. /**
  22. * @var \Magento\Framework\App\Response\Http\FileFactory
  23. */
  24. protected $_fileFactory;
  25. /**
  26. * @var \Magento\Framework\Stdlib\DateTime\Filter\Date
  27. */
  28. protected $_dateFilter;
  29. /**
  30. * @param \Magento\Backend\App\Action\Context $context
  31. * @param \Magento\Framework\Registry $coreRegistry
  32. * @param \Magento\Framework\App\Response\Http\FileFactory $fileFactory
  33. * @param \Magento\Framework\Stdlib\DateTime\Filter\Date $dateFilter
  34. */
  35. public function __construct(
  36. \Magento\Backend\App\Action\Context $context,
  37. \Magento\Framework\Registry $coreRegistry,
  38. \Magento\Framework\App\Response\Http\FileFactory $fileFactory,
  39. \Magento\Framework\Stdlib\DateTime\Filter\Date $dateFilter
  40. ) {
  41. parent::__construct($context);
  42. $this->_coreRegistry = $coreRegistry;
  43. $this->_fileFactory = $fileFactory;
  44. $this->_dateFilter = $dateFilter;
  45. }
  46. /**
  47. * Initiate rule
  48. *
  49. * @return void
  50. */
  51. protected function _initRule()
  52. {
  53. $this->_coreRegistry->register(
  54. \Magento\SalesRule\Model\RegistryConstants::CURRENT_SALES_RULE,
  55. $this->_objectManager->create(\Magento\SalesRule\Model\Rule::class)
  56. );
  57. $id = (int)$this->getRequest()->getParam('id');
  58. if (!$id && $this->getRequest()->getParam('rule_id')) {
  59. $id = (int)$this->getRequest()->getParam('rule_id');
  60. }
  61. if ($id) {
  62. $this->_coreRegistry->registry(\Magento\SalesRule\Model\RegistryConstants::CURRENT_SALES_RULE)->load($id);
  63. }
  64. }
  65. /**
  66. * Initiate action
  67. *
  68. * @return $this
  69. */
  70. protected function _initAction()
  71. {
  72. $this->_view->loadLayout();
  73. $this->_setActiveMenu('Magento_SalesRule::promo_quote')->_addBreadcrumb(__('Promotions'), __('Promotions'));
  74. return $this;
  75. }
  76. }