sfFormPropel::saveFile PHP Method

saveFile() protected method

Saves the current file for the field.
protected saveFile ( string $field, string $filename = null, sfValidatedFile $file = null ) : string
$field string The field name
$filename string The file name of the file to save
$file sfValidatedFile The validated file to save
return string The filename used to save the file
    protected function saveFile($field, $filename = null, sfValidatedFile $file = null)
    {
        if (!$this->validatorSchema[$field] instanceof sfValidatorFile) {
            throw new LogicException(sprintf('You cannot save the current file for field "%s" as the field is not a file.', $field));
        }
        if (null === $file) {
            $file = $this->getValue($field);
        }
        $column = call_user_func(array($this->getPeer(), 'translateFieldName'), $field, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_PHPNAME);
        $method = sprintf('generate%sFilename', $column);
        if (null !== $filename) {
            return $file->save($filename);
        } else {
            if (method_exists($this, $method)) {
                return $file->save($this->{$method}($file));
            } else {
                if (method_exists($this->getObject(), $method)) {
                    return $file->save($this->getObject()->{$method}($file));
                } else {
                    return $file->save();
                }
            }
        }
    }