Catalog.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. /**
  7. * Backend Catalog Price Rules controller
  8. *
  9. * @author Magento Core Team <core@magentocommerce.com>
  10. */
  11. namespace Magento\CatalogRule\Controller\Adminhtml\Promo;
  12. use Magento\Backend\App\Action;
  13. use Magento\Backend\App\Action\Context;
  14. use Magento\Framework\Registry;
  15. use Magento\Framework\Stdlib\DateTime\Filter\Date;
  16. abstract class Catalog extends Action
  17. {
  18. /**
  19. * Authorization level of a basic admin session
  20. *
  21. * @see _isAllowed()
  22. */
  23. const ADMIN_RESOURCE = 'Magento_CatalogRule::promo_catalog';
  24. /**
  25. * Dirty rules notice message
  26. *
  27. *
  28. * @var string
  29. */
  30. protected $_dirtyRulesNoticeMessage;
  31. /**
  32. * Core registry
  33. *
  34. * @var Registry
  35. */
  36. protected $_coreRegistry = null;
  37. /**
  38. * Date filter instance
  39. *
  40. * @var \Magento\Framework\Stdlib\DateTime\Filter\Date
  41. */
  42. protected $_dateFilter;
  43. /**
  44. * Constructor
  45. *
  46. * @param Context $context
  47. * @param Registry $coreRegistry
  48. * @param Date $dateFilter
  49. */
  50. public function __construct(Context $context, Registry $coreRegistry, Date $dateFilter)
  51. {
  52. parent::__construct($context);
  53. $this->_coreRegistry = $coreRegistry;
  54. $this->_dateFilter = $dateFilter;
  55. }
  56. /**
  57. * Init action
  58. *
  59. * @return $this
  60. */
  61. protected function _initAction()
  62. {
  63. $this->_view->loadLayout();
  64. $this->_setActiveMenu(
  65. 'Magento_CatalogRule::promo_catalog'
  66. )->_addBreadcrumb(
  67. __('Promotions'),
  68. __('Promotions')
  69. );
  70. return $this;
  71. }
  72. /**
  73. * Set dirty rules notice message
  74. *
  75. * @param string $dirtyRulesNoticeMessage
  76. * @return void
  77. * @codeCoverageIgnore
  78. */
  79. public function setDirtyRulesNoticeMessage($dirtyRulesNoticeMessage)
  80. {
  81. $this->_dirtyRulesNoticeMessage = $dirtyRulesNoticeMessage;
  82. }
  83. /**
  84. * Get dirty rules notice message
  85. *
  86. * @return string
  87. */
  88. public function getDirtyRulesNoticeMessage()
  89. {
  90. $defaultMessage = __(
  91. 'We found updated rules that are not applied. Please click "Apply Rules" to update your catalog.'
  92. );
  93. return $this->_dirtyRulesNoticeMessage ? $this->_dirtyRulesNoticeMessage : $defaultMessage;
  94. }
  95. }