Conditions | 4 |
Paths | 4 |
Total Lines | 18 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
10 | public function download($request) |
||
11 | { |
||
12 | $importerClassName = $request->param("ID"); |
||
13 | $objectClassName = str_replace("Import", "", $importerClassName); |
||
14 | if (class_exists($objectClassName)) { |
||
15 | $obj = new $importerClassName($objectClassName); |
||
16 | if ($obj instanceof CsvBulkLoader) { |
||
17 | if ($fileData = $obj->getExportExampleData()) { |
||
18 | $fileName = $objectClassName.".csv"; |
||
19 | return SS_HTTPRequest::send_file($fileData, $fileName, 'text/csv'); |
||
20 | } else { |
||
21 | user_error("Could not export import example", E_USER_ERROR); |
||
22 | } |
||
23 | } else { |
||
24 | user_error("$obj->class is not an instance of CsvBulkLoader"); |
||
25 | } |
||
26 | } |
||
27 | } |
||
28 | |||
34 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.