Attachment/AttachmentHandler.php
protected function saveToDatabase(File $file, AttachableObjectInterface $object, $fieldName, FileKey $fileKey, $customFilename = null)
    {
        $attachment = $this->getOrCreateAttachment($file, $object, $fieldName, $fileKey);
        $link = $this->createAttachmentLink($file, $object, $fieldName, $attachment, $customFilename);
        
        if (in_array($fieldName, $object->getAttachableFieldNames()))
        {
            $method = 'set'.$fieldName.'Attachment';
        
            if (!method_exists($object, $method))
            {
                throw new InvalidAttachableFieldNameException('Fieldname setter for '.$fieldName.' does not exist in '.get_class($object));
            }
            
            $object->$method($attachment);
            $link->setIsCurrent(true);
            
            AttachmentLinkQuery::create()
                ->filterByAttachableObject($object)
                ->filterByModelField($fieldName)
                ->doUpdate(array('IsCurrent' => false), \Propel::getConnection())
            ;
        }
        
        $link->save();
        
        return $attachment;
    }
protected function saveToDatabase(File $file, AttachableObjectInterface $object, $fieldName, FileKey $fileKey, $customFilename = null)
    {
        $attachment = $this->getOrCreateAttachment($file, $object, $fieldName, $fileKey);
        $link = $this->createAttachmentLink($file, $object, $fieldName, $attachment, $customFilename);
        
        if (in_array($fieldName, $object->getAttachableFieldNames()))
        {
            $method = 'set'.$fieldName.'Attachment';
        
            if (!method_exists($object, $method))
            {
                throw new InvalidAttachableFieldNameException('Fieldname setter for '.$fieldName.' does not exist in '.get_class($object));
            }
            
            $object->$method($attachment);
            $link->setIsCurrent(true);
            
            AttachmentLinkQuery::create()
                ->filterByAttachableObject($object)
                ->filterByModelField($fieldName)
                ->doUpdate(array('IsCurrent' => false), \Propel::getConnection())
            ;
        }
        
        $link->save();
        
        return $attachment;
    }
protected function saveToDatabase ( File $ file , AttachableObjectInterface $ object , $ fieldName , FileKey $ fileKey , $ customFilename = null ) { $ attachment = $ this -> getOrCreateAttachment ( $ file , $ object , $ fieldName , $ fileKey ) ; $ link = $ this -> createAttachmentLink ( $ file , $ object , $ fieldName , $ attachment , $ customFilename ) ; if ( in_array ( $ fieldName , $ object -> getAttachableFieldNames ( ) ) ) { $ method = 'set' . $ fieldName . 'Attachment' ; if ( ! method_exists ( $ object , $ method ) ) { throw new InvalidAttachableFieldNameException ( 'Fieldname setter for ' . $ fieldName . ' does not exist in ' . get_class ( $ object ) ) ; } $ object -> $ method ( $ attachment ) ; $ link -> setIsCurrent ( true ) ; AttachmentLinkQuery :: create ( ) -> filterByAttachableObject ( $ object ) -> filterByModelField ( $ fieldName ) -> doUpdate ( array ( 'IsCurrent' => false ) , \ Propel :: getConnection ( ) ) ; } $ link -> save ( ) ; return $ attachment ; }
Perform filling and saving of attachment database object

@throws InvalidAttachableFieldNameException

@param File $file
@param AttachableObjectInterface $object
@param string $fieldName
@param FileKey $fileKey

@return Attachment
Perform filling and saving of attachment database object