Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ReportStatus.php
Go to the documentation of this file.
1 <?php
6 declare(strict_types=1);
7 
8 namespace Magento\Reports\Model;
9 
12 
17 {
21  private $scopeConfig;
22 
26  public function __construct(ScopeConfigInterface $scopeConfig)
27  {
28  $this->scopeConfig = $scopeConfig;
29  }
30 
38  public function isReportEnabled(string $reportEventType): bool
39  {
40  return (bool)$this->scopeConfig->getValue('reports/options/enabled')
41  && (bool)$this->scopeConfig->getValue($this->getConfigPathByEventType($reportEventType));
42  }
43 
49  private function getConfigPathByEventType(string $reportEventType): string
50  {
51  $typeToPathMap = [
52  Event::EVENT_PRODUCT_VIEW => 'reports/options/product_view_enabled',
53  Event::EVENT_PRODUCT_SEND => 'reports/options/product_send_enabled',
54  Event::EVENT_PRODUCT_COMPARE => 'reports/options/product_compare_enabled',
55  Event::EVENT_PRODUCT_TO_CART => 'reports/options/product_to_cart_enabled',
56  Event::EVENT_PRODUCT_TO_WISHLIST => 'reports/options/product_to_wishlist_enabled',
57  Event::EVENT_WISHLIST_SHARE => 'reports/options/wishlist_share_enabled',
58  ];
59 
60  if (!isset($typeToPathMap[$reportEventType])) {
61  throw new InputException(
62  __('System configuration is not found for report event type "%1"', $reportEventType)
63  );
64  }
65 
66  return $typeToPathMap[$reportEventType];
67  }
68 }
isReportEnabled(string $reportEventType)
__()
Definition: __.php:13
__construct(ScopeConfigInterface $scopeConfig)