Context.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <?php
  2. /**
  3. * Abstract model context
  4. *
  5. * Copyright © Magento, Inc. All rights reserved.
  6. * See COPYING.txt for license details.
  7. */
  8. namespace Magento\Framework\Model;
  9. /**
  10. * Constructor modification point for Magento\Framework\Model\AbstractModel.
  11. *
  12. * All context classes were introduced to allow for backwards compatible constructor modifications
  13. * of classes that were supposed to be extended by extension developers.
  14. *
  15. * Do not call methods of this class directly.
  16. *
  17. * As Magento moves from inheritance-based APIs all such classes will be deprecated together with
  18. * the classes they were introduced for.
  19. *
  20. * @api
  21. * @since 100.0.2
  22. */
  23. class Context implements \Magento\Framework\ObjectManager\ContextInterface
  24. {
  25. /**
  26. * @var \Magento\Framework\Event\ManagerInterface
  27. */
  28. protected $_eventDispatcher;
  29. /**
  30. * @var \Magento\Framework\App\CacheInterface
  31. */
  32. protected $_cacheManager;
  33. /**
  34. * @var \Psr\Log\LoggerInterface
  35. */
  36. protected $_logger;
  37. /**
  38. * @var \Magento\Framework\App\State
  39. */
  40. protected $_appState;
  41. /**
  42. * @var \Magento\Framework\Model\ActionValidator\RemoveAction
  43. */
  44. protected $_actionValidator;
  45. /**
  46. * @param \Psr\Log\LoggerInterface $logger
  47. * @param \Magento\Framework\Event\ManagerInterface $eventDispatcher
  48. * @param \Magento\Framework\App\CacheInterface $cacheManager
  49. * @param \Magento\Framework\App\State $appState
  50. * @param \Magento\Framework\Model\ActionValidator\RemoveAction $actionValidator
  51. */
  52. public function __construct(
  53. \Psr\Log\LoggerInterface $logger,
  54. \Magento\Framework\Event\ManagerInterface $eventDispatcher,
  55. \Magento\Framework\App\CacheInterface $cacheManager,
  56. \Magento\Framework\App\State $appState,
  57. \Magento\Framework\Model\ActionValidator\RemoveAction $actionValidator
  58. ) {
  59. $this->_eventDispatcher = $eventDispatcher;
  60. $this->_cacheManager = $cacheManager;
  61. $this->_appState = $appState;
  62. $this->_logger = $logger;
  63. $this->_actionValidator = $actionValidator;
  64. }
  65. /**
  66. * @return \Magento\Framework\App\CacheInterface
  67. */
  68. public function getCacheManager()
  69. {
  70. return $this->_cacheManager;
  71. }
  72. /**
  73. * @return \Magento\Framework\Event\ManagerInterface
  74. */
  75. public function getEventDispatcher()
  76. {
  77. return $this->_eventDispatcher;
  78. }
  79. /**
  80. * @return \Psr\Log\LoggerInterface
  81. */
  82. public function getLogger()
  83. {
  84. return $this->_logger;
  85. }
  86. /**
  87. * @return \Magento\Framework\App\State
  88. */
  89. public function getAppState()
  90. {
  91. return $this->_appState;
  92. }
  93. /**
  94. * @return \Magento\Framework\Model\ActionValidator\RemoveAction
  95. */
  96. public function getActionValidator()
  97. {
  98. return $this->_actionValidator;
  99. }
  100. }