Customer.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. /**
  7. *
  8. * Customer reports admin controller
  9. *
  10. * @author Magento Core Team <core@magentocommerce.com>
  11. */
  12. namespace Magento\Reports\Controller\Adminhtml\Report;
  13. /**
  14. * @api
  15. * @since 100.0.2
  16. */
  17. abstract class Customer extends \Magento\Backend\App\Action
  18. {
  19. /**
  20. * @var \Magento\Framework\App\Response\Http\FileFactory
  21. */
  22. protected $_fileFactory;
  23. /**
  24. * @param \Magento\Backend\App\Action\Context $context
  25. * @param \Magento\Framework\App\Response\Http\FileFactory $fileFactory
  26. */
  27. public function __construct(
  28. \Magento\Backend\App\Action\Context $context,
  29. \Magento\Framework\App\Response\Http\FileFactory $fileFactory
  30. ) {
  31. $this->_fileFactory = $fileFactory;
  32. parent::__construct($context);
  33. }
  34. /**
  35. * Add reports and customer breadcrumbs
  36. *
  37. * @return $this
  38. */
  39. public function _initAction()
  40. {
  41. $act = $this->getRequest()->getActionName();
  42. if (!$act) {
  43. $act = 'default';
  44. }
  45. $this->_view->loadLayout();
  46. $this->_addBreadcrumb(__('Reports'), __('Reports'));
  47. $this->_addBreadcrumb(__('Customers'), __('Customers'));
  48. return $this;
  49. }
  50. /**
  51. * Determine if action is allowed for reports module
  52. *
  53. * @return bool
  54. */
  55. protected function _isAllowed()
  56. {
  57. switch ($this->getRequest()->getActionName()) {
  58. case 'accounts':
  59. return $this->_authorization->isAllowed('Magento_Reports::accounts');
  60. break;
  61. case 'orders':
  62. return $this->_authorization->isAllowed('Magento_Reports::customers_orders');
  63. break;
  64. case 'totals':
  65. return $this->_authorization->isAllowed('Magento_Reports::totals');
  66. break;
  67. default:
  68. return $this->_authorization->isAllowed('Magento_Reports::customers');
  69. break;
  70. }
  71. }
  72. }