Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AbstractWriter.php
Go to the documentation of this file.
1 <?php
7 
10 
14 abstract class AbstractWriter implements WriterInterface
15 {
21  protected $writer;
22 
28  public function __construct($writer)
29  {
30  $this->writer = $writer;
31  }
32 
38  public function write(array $options, ConfigInterface $config)
39  {
40  $this->checkOptions($options);
41 
42  $this->writeToFile($options['report_filename'], $this->prepareData($config));
43  }
44 
52  protected function checkOptions($options)
53  {
54  if (!isset($options['report_filename']) || empty($options['report_filename'])) {
55  throw new \InvalidArgumentException('Writing error: Passed option "report_filename" is wrong.');
56  }
57  }
58 
65  abstract protected function prepareData($config);
66 
74  protected function writeToFile($filename, $data)
75  {
76  $this->writer->saveData($filename, $data);
77  }
78 }
$config
Definition: fraud_order.php:17