Dailydeal.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. namespace Smartwave\Dailydeals\Controller\Adminhtml;
  3. abstract class Dailydeal extends \Magento\Backend\App\Action
  4. {
  5. /**
  6. * Dailydeal Factory
  7. *
  8. * @var \Smartwave\Dailydeals\Model\DailydealFactory
  9. */
  10. protected $dailydealFactory;
  11. /**
  12. * Core registry
  13. *
  14. * @var \Magento\Framework\Registry
  15. */
  16. protected $coreRegistry;
  17. /**
  18. * Result redirect factory
  19. *
  20. * @var \Magento\Backend\Model\View\Result\RedirectFactory
  21. */
  22. protected $resultRedirectFactory;
  23. /**
  24. * constructor
  25. *
  26. * @param \Smartwave\Dailydeals\Model\DailydealFactory $dailydealFactory
  27. * @param \Magento\Framework\Registry $coreRegistry
  28. * @param \Magento\Backend\Model\View\Result\RedirectFactory $resultRedirectFactory
  29. * @param \Magento\Backend\App\Action\Context $context
  30. */
  31. public function __construct(
  32. \Smartwave\Dailydeals\Model\DailydealFactory $dailydealFactory,
  33. \Magento\Framework\Registry $coreRegistry,
  34. \Magento\Backend\App\Action\Context $context
  35. ) {
  36. $this->dailydealFactory = $dailydealFactory;
  37. $this->coreRegistry = $coreRegistry;
  38. $this->resultRedirectFactory = $context->getResultRedirectFactory();
  39. parent::__construct($context);
  40. }
  41. /**
  42. * Init Dailydeal
  43. *
  44. * @return \Smartwave\Dailydeals\Model\Dailydeal
  45. */
  46. protected function initDailydeal()
  47. {
  48. $dailydealId = (int) $this->getRequest()->getParam('dailydeal_id');
  49. /** @var \Smartwave\Dailydeals\Model\Dailydeal $dailydeal */
  50. $dailydeal = $this->dailydealFactory->create();
  51. if ($dailydealId) {
  52. $dailydeal->load($dailydealId);
  53. }
  54. $this->coreRegistry->register('sw_dailydeals_dailydeal', $dailydeal);
  55. return $dailydeal;
  56. }
  57. }