Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ReportModulesInfo.php
Go to the documentation of this file.
1 <?php
7 
10 
15 {
19  protected $config;
20 
24  protected $collect;
25 
29  protected $systemFactory;
30 
34  protected $jsonEncoder;
35 
44  public function __construct(
47  \Magento\NewRelicReporting\Model\SystemFactory $systemFactory,
48  \Magento\Framework\Json\EncoderInterface $jsonEncoder
49  ) {
50  $this->config = $config;
51  $this->collect = $collect;
52  $this->systemFactory = $systemFactory;
53  $this->jsonEncoder = $jsonEncoder;
54  }
55 
61  public function report()
62  {
63  if ($this->config->isNewRelicEnabled()) {
64  $moduleData = $this->collect->getModuleData();
65  if (count($moduleData['changes']) > 0) {
66  foreach ($moduleData['changes'] as $change) {
67  switch ($change['type']) {
68  case Config::ENABLED:
69  $modelData = [
70  'type' => Config::MODULE_ENABLED,
71  'action' => $this->jsonEncoder->encode($change),
72  ];
73  break;
74  case Config::DISABLED:
75  $modelData = [
76  'type' => Config::MODULE_DISABLED,
77  'action' => $this->jsonEncoder->encode($change),
78  ];
79  break;
80  case Config::INSTALLED:
81  $modelData = [
82  'type' => Config::MODULE_INSTALLED,
83  'action' => $this->jsonEncoder->encode($change),
84  ];
85  break;
87  $modelData = [
89  'action' => $this->jsonEncoder->encode($change),
90  ];
91  break;
92  }
94  $systemModel = $this->systemFactory->create();
95  $systemModel->setData($modelData);
96  $systemModel->save();
97  }
98  }
99  }
100 
101  return $this;
102  }
103 }
__construct(Config $config, Collect $collect, \Magento\NewRelicReporting\Model\SystemFactory $systemFactory, \Magento\Framework\Json\EncoderInterface $jsonEncoder)
$change