PHP Класс 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()
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$file Symfony\Component\HttpFoundation\File\UploadedFile
$fileName string
$oldFileName string

Открытые методы

Метод Описание
__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()

Защищенные методы

Метод Описание
__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

Описание методов

__construct() защищенный Метод

protected __construct ( string $fileName )
$fileName string

__toString() публичный Метод

Returns a string representation of the image.
public __toString ( ) : string
Результат string

fromString() публичный статический Метод

public static fromString ( string $fileName ) : static
$fileName string
Результат static

fromUploadedFile() публичный статический Метод

public static fromUploadedFile ( Symfony\Component\HttpFoundation\File\UploadedFile $uploadedFile = null ) : static
$uploadedFile Symfony\Component\HttpFoundation\File\UploadedFile
Результат static

getAbsolutePath() публичный Метод

public getAbsolutePath ( ) : string | null
Результат string | null

getFile() публичный Метод

Get file.
public getFile ( ) : Symfony\Component\HttpFoundation\File\UploadedFile
Результат Symfony\Component\HttpFoundation\File\UploadedFile

getFileName() публичный Метод

public getFileName ( ) : string
Результат string

getTrimmedUploadDir() защищенный Метод

protected getTrimmedUploadDir ( ) : string
Результат string

getUploadDir() абстрактный защищенный Метод

The base directory is always the src/Frontend/Files/ directory
abstract protected getUploadDir ( ) : string
Результат string

getUploadRootDir() защищенный Метод

protected getUploadRootDir ( ) : string
Результат string

getWebPath() публичный Метод

public getWebPath ( ) : string
Результат string

markForDeletion() публичный Метод

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

prepareToUpload() публичный Метод

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

remove() публичный Метод

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

removeOldFile() защищенный Метод

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

setFile() публичный Метод

Sets file.
public setFile ( Symfony\Component\HttpFoundation\File\UploadedFile $file = null ) : static
$file Symfony\Component\HttpFoundation\File\UploadedFile
Результат static

upload() публичный Метод

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

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
protected writeFileToDisk ( )

Описание свойств

$file защищенное свойство

protected UploadedFile,Symfony\Component\HttpFoundation\File $file
Результат Symfony\Component\HttpFoundation\File\UploadedFile

$fileName защищенное свойство

protected string $fileName
Результат string

$oldFileName защищенное свойство

protected string $oldFileName
Результат string