Extending the CsvView class and RequestHandler
larsgw opened this issue · 2 comments
larsgw commented
I am using CsvView, but I have to pre-process the data before serialization. Given the amount of code involved, I thought I'd put it in a separate view class rather than using _extract
. However, when I point CSV in the viewClassMap
to my custom view class, the value gets overwritten by this plugin.
cakephp-csvview/config/bootstrap.php
Lines 11 to 16 in 3b105f4
I can make a PR to check whether the config is set before overriding it, would that be reasonable for the project? Something like this.
if ($controller->components()->has('RequestHandler') &&
$controller->RequestHandler->getConfig('viewClassMap.csv') === null) {
$controller->RequestHandler->setConfig('viewClassMap.csv', 'CsvView.Csv');
}
ADmad commented
You can simply skip loading the bootstrap by using 'bootstrap' => false
option when loading the plugin.
larsgw commented
Ah, that works. Thank you!