PHP Class Spatie\MediaLibrary\FileAdder\FileAdder

ファイルを表示 Open project: spatie/laravel-medialibrary

Protected Properties

Property Type Description
$config Illuminate\Contracts\Cache\Repository
$customProperties array
$diskName string
$file string | Symfony\Component\HttpFoundation\File\UploadedFile
$fileName string
$filesystem Spatie\MediaLibrary\Filesystem
$mediaName string
$pathToFile string
$preserveOriginal boolean
$properties array
$subject subject

Public Methods

Method Description
__construct ( Filesystem $fileSystem, Illuminate\Contracts\Cache\Repository $config )
preservingOriginal ( ) When adding the file to the media library, the original file will be preserved.
setFile ( string | Symfony\Component\HttpFoundation\File\UploadedFile $file ) Set the file that needs to be imported.
setFileName ( string $fileName ) Set the name of the file that is stored on disk.
setName ( string $name ) Set the name of the media object.
setSubject ( Model $subject ) : FileAdder
toCollection ( string $collectionName = 'default', string $diskName = '' ) : Media Set the collection name where to import the file.
toCollectionOnDisk ( string $collectionName = 'default', string $diskName = '' ) : Media
toMediaLibrary ( string $collectionName = 'default', string $diskName = '' ) : Media Set the target media collection to default.
toMediaLibraryOnDisk ( string $collectionName = 'default', string $diskName = '' ) : Media Set the target media collection to default.
usingFileName ( string $fileName ) Set the name of the file that is stored on disk.
usingName ( string $name ) Set the name of the media object.
withAttributes ( array $properties ) Set attributes on the model.
withCustomProperties ( array $customProperties ) Set the metadata.
withProperties ( array $properties ) Set properties on the model.

Protected Methods

Method Description
determineDiskName ( string $diskName ) : string Determine the disk to be used.
sanitizeFileName ( string $fileName ) : string Sanitize the given file name.

Method Details

__construct() public method

public __construct ( Filesystem $fileSystem, Illuminate\Contracts\Cache\Repository $config )
$fileSystem Spatie\MediaLibrary\Filesystem
$config Illuminate\Contracts\Cache\Repository

determineDiskName() protected method

Determine the disk to be used.
protected determineDiskName ( string $diskName ) : string
$diskName string
return string

preservingOriginal() public method

When adding the file to the media library, the original file will be preserved.
public preservingOriginal ( )

sanitizeFileName() protected method

Sanitize the given file name.
protected sanitizeFileName ( string $fileName ) : string
$fileName string
return string

setFile() public method

Set the file that needs to be imported.
public setFile ( string | Symfony\Component\HttpFoundation\File\UploadedFile $file )
$file string | Symfony\Component\HttpFoundation\File\UploadedFile

setFileName() public method

Set the name of the file that is stored on disk.
public setFileName ( string $fileName )
$fileName string

setName() public method

Set the name of the media object.
public setName ( string $name )
$name string

setSubject() public method

public setSubject ( Model $subject ) : FileAdder
$subject Illuminate\Database\Eloquent\Model
return FileAdder

toCollection() public method

Will also start the import process.
public toCollection ( string $collectionName = 'default', string $diskName = '' ) : Media
$collectionName string
$diskName string
return Spatie\MediaLibrary\Media

toCollectionOnDisk() public method

public toCollectionOnDisk ( string $collectionName = 'default', string $diskName = '' ) : Media
$collectionName string
$diskName string
return Spatie\MediaLibrary\Media

toMediaLibrary() public method

Will also start the import process.
public toMediaLibrary ( string $collectionName = 'default', string $diskName = '' ) : Media
$collectionName string
$diskName string
return Spatie\MediaLibrary\Media

toMediaLibraryOnDisk() public method

Will also start the import process.
public toMediaLibraryOnDisk ( string $collectionName = 'default', string $diskName = '' ) : Media
$collectionName string
$diskName string
return Spatie\MediaLibrary\Media

usingFileName() public method

Set the name of the file that is stored on disk.
public usingFileName ( string $fileName )
$fileName string

usingName() public method

Set the name of the media object.
public usingName ( string $name )
$name string

withAttributes() public method

Set attributes on the model.
public withAttributes ( array $properties )
$properties array

withCustomProperties() public method

Set the metadata.
public withCustomProperties ( array $customProperties )
$customProperties array

withProperties() public method

Set properties on the model.
public withProperties ( array $properties )
$properties array

Property Details

$config protected_oe property

protected Repository,Illuminate\Contracts\Cache $config
return Illuminate\Contracts\Cache\Repository

$customProperties protected_oe property

protected array $customProperties
return array

$diskName protected_oe property

protected string $diskName
return string

$file protected_oe property

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

$fileName protected_oe property

protected string $fileName
return string

$filesystem protected_oe property

protected Filesystem,Spatie\MediaLibrary $filesystem
return Spatie\MediaLibrary\Filesystem

$mediaName protected_oe property

protected string $mediaName
return string

$pathToFile protected_oe property

protected string $pathToFile
return string

$preserveOriginal protected_oe property

protected bool $preserveOriginal
return boolean

$properties protected_oe property

protected array $properties
return array

$subject protected_oe property

subject
protected $subject