To keep the execution logic as simple as possible, frequently used parameters should be outsourced in private properties and each task should be outsourced into a protected method. For methods the protected keyword should exclusively be used, in case your own methods have to be called up from the API (meaning from the parent class e.g. with the executeMethodForSubtable, further explained in the chapter Using subtables). Let us start with the opening of the CSV file in writing mode in the JobRouter temp directory:
Private methods and properties
<?php
class csvSystemActivity extends AbstractSystemActivityAPI
{
...
private $fieldDelimiter;
private $csvFile;
private $csvFilePointer;
protected function exportCsv()
{
$this->debug('exportCsv start');
$this->loadGlobalSettings();
$this->openCsvFile('w');
$this->debug('exportCsv end');
}
protected function loadGlobalSettings()
{
$this->fieldDelimiter = $this->resolveInputParameter('fieldDelimiter');
}
protected function openCsvFile($mode)
{
$this->csvFile = $this->getTempPath() . DIRECTORY_SEPARATOR . 'test.csv';
$this->debug('csvFile: '.$this->csvFile);
$this->csvFilePointer = fopen($this->csvFile, $mode);
}
}