PHP Class Common\Doctrine\ValueObject\AbstractFile

You need to implement the method getUploadDir. When using this class in an entity certain life cycle callbacks should be called prepareToUpload for @ORM\PrePersist() and @ORM\PreUpdate() upload for @ORM\PostPersist() and @ORM\PostUpdate() remove for @ORM\PostRemove()
Mostrar archivo Open project: forkcms/forkcms Class Usage Examples

Protected Properties

Property Type Description
$file Symfony\Component\HttpFoundation\File\UploadedFile
$fileName string
$oldFileName string

Public Methods

Method Description
__toString ( ) : string Returns a string representation of the image.
fromString ( string $fileName ) : static
fromUploadedFile ( Symfony\Component\HttpFoundation\File\UploadedFile $uploadedFile = null ) : static
getAbsolutePath ( ) : string | null
getFile ( ) : Symfony\Component\HttpFoundation\File\UploadedFile Get file.
getFileName ( ) : string
getWebPath ( ) : string
markForDeletion ( ) The next time doctrine saves this to the database the file will be removed
prepareToUpload ( ) This function should be called for the life cycle events @ORM\PrePersist() and @ORM\PreUpdate()
remove ( ) This function should be called for the life cycle event @ORM\PostRemove()
setFile ( Symfony\Component\HttpFoundation\File\UploadedFile $file = null ) : static Sets file.
upload ( ) This function should be called for the life cycle events @ORM\PostPersist() and @ORM\PostUpdate()

Protected Methods

Method Description
__construct ( string $fileName )
getTrimmedUploadDir ( ) : string
getUploadDir ( ) : string The dir in the web folder where the file needs to be uploaded.
getUploadRootDir ( ) : string
removeOldFile ( ) This will remove the old file, can be extended to add extra functionality
writeFileToDisk ( ) if there is an error when moving the file, an exception will be automatically thrown by move(). This will properly prevent the entity from being persisted to the database on error

Method Details

__construct() protected method

protected __construct ( string $fileName )
$fileName string

__toString() public method

Returns a string representation of the image.
public __toString ( ) : string
return string

fromString() public static method

public static fromString ( string $fileName ) : static
$fileName string
return static

fromUploadedFile() public static method

public static fromUploadedFile ( Symfony\Component\HttpFoundation\File\UploadedFile $uploadedFile = null ) : static
$uploadedFile Symfony\Component\HttpFoundation\File\UploadedFile
return static

getAbsolutePath() public method

public getAbsolutePath ( ) : string | null
return string | null

getFile() public method

Get file.
public getFile ( ) : Symfony\Component\HttpFoundation\File\UploadedFile
return Symfony\Component\HttpFoundation\File\UploadedFile

getFileName() public method

public getFileName ( ) : string
return string

getTrimmedUploadDir() protected method

protected getTrimmedUploadDir ( ) : string
return string

getUploadDir() abstract protected method

The base directory is always the src/Frontend/Files/ directory
abstract protected getUploadDir ( ) : string
return string

getUploadRootDir() protected method

protected getUploadRootDir ( ) : string
return string

getWebPath() public method

public getWebPath ( ) : string
return string

markForDeletion() public method

The next time doctrine saves this to the database the file will be removed
public markForDeletion ( )

prepareToUpload() public method

This function should be called for the life cycle events @ORM\PrePersist() and @ORM\PreUpdate()
public prepareToUpload ( )

remove() public method

This function should be called for the life cycle event @ORM\PostRemove()
public remove ( )

removeOldFile() protected method

This will remove the old file, can be extended to add extra functionality
protected removeOldFile ( )

setFile() public method

Sets file.
public setFile ( Symfony\Component\HttpFoundation\File\UploadedFile $file = null ) : static
$file Symfony\Component\HttpFoundation\File\UploadedFile
return static

upload() public method

This function should be called for the life cycle events @ORM\PostPersist() and @ORM\PostUpdate()
public upload ( )

writeFileToDisk() protected method

if there is an error when moving the file, an exception will be automatically thrown by move(). This will properly prevent the entity from being persisted to the database on error
protected writeFileToDisk ( )

Property Details

$file protected_oe property

protected UploadedFile,Symfony\Component\HttpFoundation\File $file
return Symfony\Component\HttpFoundation\File\UploadedFile

$fileName protected_oe property

protected string $fileName
return string

$oldFileName protected_oe property

protected string $oldFileName
return string