Attachment/AttachmentHandler.php
protected function getOrCreateAttachment(File $file, AttachableObjectInterface $object, $fieldName, FileKey $fileKey)
    {
        $attachment = $this->getAttachment($fileKey->getKey());
        
        if (null === $attachment)
        {
            $schema = $this->getSchemaForObject($object, $fieldName);
            
            $attachment = new Attachment();
            $attachment
                ->setFileKey($fileKey->getKey())
                ->setFileSize($file->getSize())
                ->setFileType($file->getMimeType())
                ->setStorageName($schema->getStorage()->getName())
                ->setStorageDepth($schema->getStorageDepth())
                ->setHashType($schema->getHashCallableAsString())
            ;
        }
        
        return $attachment;
    }
protected function getOrCreateAttachment(File $file, AttachableObjectInterface $object, $fieldName, FileKey $fileKey)
    {
        $attachment = $this->getAttachment($fileKey->getKey());
        
        if (null === $attachment)
        {
            $schema = $this->getSchemaForObject($object, $fieldName);
            
            $attachment = new Attachment();
            $attachment
                ->setFileKey($fileKey->getKey())
                ->setFileSize($file->getSize())
                ->setFileType($file->getMimeType())
                ->setStorageName($schema->getStorage()->getName())
                ->setStorageDepth($schema->getStorageDepth())
                ->setHashType($schema->getHashCallableAsString())
            ;
        }
        
        return $attachment;
    }
protected function getOrCreateAttachment ( File $ file , AttachableObjectInterface $ object , $ fieldName , FileKey $ fileKey ) { $ attachment = $ this -> getAttachment ( $ fileKey -> getKey ( ) ) ; if ( null === $ attachment ) { $ schema = $ this -> getSchemaForObject ( $ object , $ fieldName ) ; $ attachment = new Attachment ( ) ; $ attachment -> setFileKey ( $ fileKey -> getKey ( ) ) -> setFileSize ( $ file -> getSize ( ) ) -> setFileType ( $ file -> getMimeType ( ) ) -> setStorageName ( $ schema -> getStorage ( ) -> getName ( ) ) -> setStorageDepth ( $ schema -> getStorageDepth ( ) ) -> setHashType ( $ schema -> getHashCallableAsString ( ) ) ; } return $ attachment ; }
Get a new Attachment object or an existing one if a file with the same key was already stored.

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

@return Attachment
Get a new Attachment object or an existing one if a file with the same key was already stored .