Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ReportSystemCacheFlush.php
Go to the documentation of this file.
1 <?php
7 
11 
16 {
20  protected $config;
21 
25  protected $systemFactory;
26 
30  protected $jsonEncoder;
31 
37  public function __construct(
39  \Magento\NewRelicReporting\Model\SystemFactory $systemFactory,
40  \Magento\Framework\Json\EncoderInterface $jsonEncoder
41  ) {
42  $this->config = $config;
43  $this->systemFactory = $systemFactory;
44  $this->jsonEncoder = $jsonEncoder;
45  }
46 
54  public function execute(Observer $observer)
55  {
56  if ($this->config->isNewRelicEnabled()) {
57  $jsonData = ['status' => 'updated'];
58 
59  $modelData = [
60  'type' => Config::FLUSH_CACHE,
61  'action' => $this->jsonEncoder->encode($jsonData)
62  ];
63 
65  $systemModel = $this->systemFactory->create();
66  $systemModel->setData($modelData);
67  $systemModel->save();
68  }
69  }
70 }
__construct(Config $config, \Magento\NewRelicReporting\Model\SystemFactory $systemFactory, \Magento\Framework\Json\EncoderInterface $jsonEncoder)