/**
* (non-PHPdoc)
* @see PAGI\CallSpool.ICallSpool::spool()
*/
public function spool(CallFile $call, $schedule = false)
{
$filename = tempnam($this->_tmpDir, 'PAGICallFile');
if ($filename === false) {
throw new CallSpoolException('Could generate temporary filename');
}
if (@file_put_contents($filename, $call->serialize()) === false) {
@unlink($filename);
throw new CallSpoolException('Error writing: ' . $filename);
}
if ($schedule !== false) {
if (@touch($filename, $schedule) === false) {
@unlink($filename);
throw new CallSpoolException('Error scheduling: ' . $filename);
}
}
$newFilename = implode(DIRECTORY_SEPARATOR, array($this->_spoolDir, 'outgoing', basename($filename)));
if (@rename($filename, $newFilename) === false) {
@unlink($filename);
throw new CallSpoolException('Error spooling: ' . $newFilename);
}
return $newFilename;
}