PAGI\CallSpool\Impl\CallSpoolImpl::spool PHP Method

spool() public method

(non-PHPdoc)
public spool ( CallFile $call, $schedule = null )
$call PAGI\CallSpool\CallFile
    public function spool(CallFile $call, $schedule = null)
    {
        $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 (!is_null($schedule)) {
            if (@touch($filename, $schedule) === false) {
                @unlink($filename);
                throw new CallSpoolException('Error scheduling: ' . $filename);
            }
        }
        $newFilename = implode(DIRECTORY_SEPARATOR, array($this->spoolDir, 'outgoing', basename($filename)));
        $dir = dirname($newFilename);
        if (!file_exists($dir)) {
            if (@mkdir($dir, 0700, true) === false) {
                @unlink($filename);
                throw new CallSpoolException('Error spooling: ' . $newFilename);
            }
        }
        if (@rename($filename, $newFilename) === false) {
            @unlink($filename);
            throw new CallSpoolException('Error spooling: ' . $newFilename);
        }
        return $newFilename;
    }