Skip to content

Commit

Permalink
Add @template annotation to FileAdder (spatie#2964)
Browse files Browse the repository at this point in the history
Co-authored-by: Simon Verwaard <[email protected]>
  • Loading branch information
sforward and sforward authored Jun 24, 2022
1 parent aacf826 commit cfab5c6
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/MediaCollections/FileAdder.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
use Symfony\Component\HttpFoundation\File\File as SymfonyFile;
use Symfony\Component\HttpFoundation\File\UploadedFile;

/**
* @template TModel of \Spatie\MediaLibrary\MediaCollections\Models\Media
*/
class FileAdder
{
use Macroable;
Expand Down Expand Up @@ -214,11 +217,17 @@ public function addCustomHeaders(array $customRemoteHeaders): self
return $this;
}

/**
* @return TModel
*/
public function toMediaCollectionOnCloudDisk(string $collectionName = 'default'): Media
{
return $this->toMediaCollection($collectionName, config('filesystems.cloud'));
}

/**
* @return TModel
*/
public function toMediaCollectionFromRemote(string $collectionName = 'default', string $diskName = ''): Media
{
$storage = Storage::disk($this->file->getDisk());
Expand Down Expand Up @@ -270,6 +279,9 @@ public function toMediaCollectionFromRemote(string $collectionName = 'default',
return $media;
}

/**
* @return TModel
*/
public function toMediaCollection(string $collectionName = 'default', string $diskName = ''): Media
{
$sanitizedFileName = ($this->fileNameSanitizer)($this->fileName);
Expand Down Expand Up @@ -333,6 +345,9 @@ public function toMediaCollection(string $collectionName = 'default', string $di
return $media;
}

/**
* @return TModel
*/
public function toMediaLibrary(string $collectionName = 'default', string $diskName = ''): Media
{
return $this->toMediaCollection($collectionName, $diskName);
Expand Down

0 comments on commit cfab5c6

Please sign in to comment.