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()
Afficher le fichier Open project: forkcms/forkcms Class Usage Examples

Protected Properties

Свойство Type Description
$file Symfony\Component\HttpFoundation\File\UploadedFile
$fileName string
$oldFileName string

Méthodes publiques

Méthode 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()

Méthodes protégées

Méthode 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 méthode

protected __construct ( string $fileName )
$fileName string

__toString() public méthode

Returns a string representation of the image.
public __toString ( ) : string
Résultat string

fromString() public static méthode

public static fromString ( string $fileName ) : static
$fileName string
Résultat static

fromUploadedFile() public static méthode

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

getAbsolutePath() public méthode

public getAbsolutePath ( ) : string | null
Résultat string | null

getFile() public méthode

Get file.
public getFile ( ) : Symfony\Component\HttpFoundation\File\UploadedFile
Résultat Symfony\Component\HttpFoundation\File\UploadedFile

getFileName() public méthode

public getFileName ( ) : string
Résultat string

getTrimmedUploadDir() protected méthode

protected getTrimmedUploadDir ( ) : string
Résultat string

getUploadDir() abstract protected méthode

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

getUploadRootDir() protected méthode

protected getUploadRootDir ( ) : string
Résultat string

getWebPath() public méthode

public getWebPath ( ) : string
Résultat string

markForDeletion() public méthode

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

prepareToUpload() public méthode

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

remove() public méthode

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

removeOldFile() protected méthode

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

setFile() public méthode

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

upload() public méthode

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

writeFileToDisk() protected méthode

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
Résultat Symfony\Component\HttpFoundation\File\UploadedFile

$fileName protected_oe property

protected string $fileName
Résultat string

$oldFileName protected_oe property

protected string $oldFileName
Résultat string