Attachment/AttachmentHandler.php
protected function createAttachmentLink(File $file, AttachableObjectInterface $object, $fieldName, Attachment $attachment, $customFilename = null)
    {
        if ($file instanceof UploadedFile)
        {
            $extension = $file->getClientOriginalExtension();
            $filename = $file->getClientOriginalName();
            $basename = basename($filename, '.'.$extension);
        }
        else
        {
            $extension = $file->getExtension();
            $filename = $file->getFilename();
            $basename = $file->getBasename('.'.$extension);
        }
        
        if (null !== $customFilename)
        {
            $filename = $customFilename;
            $basename = basename($filename, '.'.$extension);
        }
        
        $link = new AttachmentLink();
        $link
            ->setAttachment($attachment)
            ->setModelName($object->getAttachableClassName())
            ->setModelId($object->getAttachableId())
            ->setModelField($fieldName)
            ->setFileName($filename)
            ->setFileExtension($extension)
            ->setCustomName($basename)
        ;
        
        return $link;
    }
protected function createAttachmentLink(File $file, AttachableObjectInterface $object, $fieldName, Attachment $attachment, $customFilename = null)
    {
        if ($file instanceof UploadedFile)
        {
            $extension = $file->getClientOriginalExtension();
            $filename = $file->getClientOriginalName();
            $basename = basename($filename, '.'.$extension);
        }
        else
        {
            $extension = $file->getExtension();
            $filename = $file->getFilename();
            $basename = $file->getBasename('.'.$extension);
        }
        
        if (null !== $customFilename)
        {
            $filename = $customFilename;
            $basename = basename($filename, '.'.$extension);
        }
        
        $link = new AttachmentLink();
        $link
            ->setAttachment($attachment)
            ->setModelName($object->getAttachableClassName())
            ->setModelId($object->getAttachableId())
            ->setModelField($fieldName)
            ->setFileName($filename)
            ->setFileExtension($extension)
            ->setCustomName($basename)
        ;
        
        return $link;
    }
protected function createAttachmentLink ( File $ file , AttachableObjectInterface $ object , $ fieldName , Attachment $ attachment , $ customFilename = null ) { if ( $ file instanceof UploadedFile ) { $ extension = $ file -> getClientOriginalExtension ( ) ; $ filename = $ file -> getClientOriginalName ( ) ; $ basename = basename ( $ filename , '.' . $ extension ) ; } else { $ extension = $ file -> getExtension ( ) ; $ filename = $ file -> getFilename ( ) ; $ basename = $ file -> getBasename ( '.' . $ extension ) ; } if ( null !== $ customFilename ) { $ filename = $ customFilename ; $ basename = basename ( $ filename , '.' . $ extension ) ; } $ link = new AttachmentLink ( ) ; $ link -> setAttachment ( $ attachment ) -> setModelName ( $ object -> getAttachableClassName ( ) ) -> setModelId ( $ object -> getAttachableId ( ) ) -> setModelField ( $ fieldName ) -> setFileName ( $ filename ) -> setFileExtension ( $ extension ) -> setCustomName ( $ basename ) ; return $ link ; }
Create new AttachmentLink object for the given parameters.

@param File $file
@param AttachableObjectInterface $object
@param string $fieldName
@param Attachment $attachment

@return AttachmentLink
Create new AttachmentLink object for the given parameters .