Product.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Review\Controller\Adminhtml;
  7. use Magento\Backend\App\Action;
  8. use Magento\Backend\App\Action\Context;
  9. use Magento\Framework\Registry;
  10. use Magento\Review\Model\ReviewFactory;
  11. use Magento\Review\Model\RatingFactory;
  12. /**
  13. * Reviews admin controller
  14. */
  15. abstract class Product extends Action
  16. {
  17. /**
  18. * Array of actions which can be processed without secret key validation
  19. *
  20. * @var array
  21. */
  22. protected $_publicActions = ['edit'];
  23. /**
  24. * Core registry
  25. *
  26. * @var \Magento\Framework\Registry
  27. */
  28. protected $coreRegistry = null;
  29. /**
  30. * Review model factory
  31. *
  32. * @var \Magento\Review\Model\ReviewFactory
  33. */
  34. protected $reviewFactory;
  35. /**
  36. * Rating model factory
  37. *
  38. * @var \Magento\Review\Model\RatingFactory
  39. */
  40. protected $ratingFactory;
  41. /**
  42. * @param \Magento\Backend\App\Action\Context $context
  43. * @param \Magento\Framework\Registry $coreRegistry
  44. * @param \Magento\Review\Model\ReviewFactory $reviewFactory
  45. * @param \Magento\Review\Model\RatingFactory $ratingFactory
  46. */
  47. public function __construct(
  48. Context $context,
  49. Registry $coreRegistry,
  50. ReviewFactory $reviewFactory,
  51. RatingFactory $ratingFactory
  52. ) {
  53. $this->coreRegistry = $coreRegistry;
  54. $this->reviewFactory = $reviewFactory;
  55. $this->ratingFactory = $ratingFactory;
  56. parent::__construct($context);
  57. }
  58. /**
  59. * @return bool
  60. */
  61. protected function _isAllowed()
  62. {
  63. switch ($this->getRequest()->getActionName()) {
  64. case 'pending':
  65. return $this->_authorization->isAllowed('Magento_Review::pending');
  66. break;
  67. default:
  68. return $this->_authorization->isAllowed('Magento_Review::reviews_all');
  69. break;
  70. }
  71. }
  72. }