1 | <?php |
||
22 | class ExportableBehavior extends Behavior implements RunnableBehaviorInterface |
||
23 | { |
||
24 | /** |
||
25 | * @var string the filename that will be used for the download. It must be without file extension! |
||
26 | */ |
||
27 | public $filename = 'exportable'; |
||
28 | /** |
||
29 | * @var ExportableServiceInterface |
||
30 | */ |
||
31 | public $exportableService; |
||
32 | /** |
||
33 | * @var array the columns to export |
||
34 | */ |
||
35 | public $columns = []; |
||
36 | /** |
||
37 | * @var array of configurable writers by type. The type is the key. |
||
38 | */ |
||
39 | public $writers = [ |
||
40 | TypeHelper::CSV => 'Box\Spout\Writer\CSV\Writer', |
||
41 | TypeHelper::XLSX => 'Box\Spout\Writer\XLSX\Writer', |
||
42 | TypeHelper::ODS => 'Box\Spout\Writer\ODS\Writer', |
||
43 | TypeHelper::XML => 'dosamigos\exportable\XmlWriter', |
||
44 | TypeHelper::JSON => 'dosamigos\exportable\JsonWriter', |
||
45 | TypeHelper::TXT => 'dosamigos\exportable\TextWriter', |
||
46 | TypeHelper::HTML => 'dosamigos\exportable\HtmlWriter' |
||
47 | ]; |
||
48 | /** |
||
49 | * @var string |
||
50 | */ |
||
51 | protected $type; |
||
52 | |||
53 | /** |
||
54 | * @inheritdoc |
||
55 | */ |
||
56 | public function init() |
||
81 | |||
82 | /** |
||
83 | * @inheritdoc |
||
84 | */ |
||
85 | public function run() |
||
94 | } |
||
95 |