Skip to content

Commit

Permalink
add UploaderFilePathAwareInterface
Browse files Browse the repository at this point in the history
  • Loading branch information
MartkCz committed May 23, 2021
1 parent bada8de commit fc15b8c
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 3 deletions.
8 changes: 7 additions & 1 deletion src/Bridge/Nette/Uploader/FileUploadUploader.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@

use Contributte\Imagist\Bridge\Nette\Exceptions\InvalidArgumentException;
use Contributte\Imagist\Bridge\Nette\Exceptions\InvalidFileUploadException;
use Contributte\Imagist\Uploader\UploaderFilePathAwareInterface;
use Contributte\Imagist\Uploader\UploaderInterface;
use Nette\Http\FileUpload;

final class FileUploadUploader implements UploaderInterface
final class FileUploadUploader implements UploaderInterface, UploaderFilePathAwareInterface
{

private FileUpload $fileUpload;
Expand Down Expand Up @@ -38,4 +39,9 @@ public function getContent(): string
return $content;
}

public function getFilePath(): string
{
return $this->fileUpload->getTemporaryFile();
}

}
8 changes: 7 additions & 1 deletion src/Bridge/Symfony/Uploader/UploadedFileUploader.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

namespace Contributte\Imagist\Bridge\Symfony\Uploader;

use Contributte\Imagist\Uploader\UploaderFilePathAwareInterface;
use Contributte\Imagist\Uploader\UploaderInterface;
use LogicException;
use Symfony\Component\HttpFoundation\File\UploadedFile;

final class UploadedFileUploader implements UploaderInterface
final class UploadedFileUploader implements UploaderInterface, UploaderFilePathAwareInterface
{

private UploadedFile $uploadedFile;
Expand All @@ -26,4 +27,9 @@ public function getContent(): string
return $content;
}

public function getFilePath(): string
{
return $this->uploadedFile->getPathname();
}

}
7 changes: 6 additions & 1 deletion src/Uploader/FilePathUploader.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Contributte\Imagist\Exceptions\CannotSaveFileException;
use Contributte\Imagist\Exceptions\InvalidArgumentException;

class FilePathUploader implements UploaderInterface
class FilePathUploader implements UploaderInterface, UploaderFilePathAwareInterface
{

private string $filePath;
Expand All @@ -28,4 +28,9 @@ public function getContent(): string
return $content;
}

public function getFilePath(): string
{
return $this->filePath;
}

}
10 changes: 10 additions & 0 deletions src/Uploader/UploaderFilePathAwareInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php declare(strict_types = 1);

namespace Contributte\Imagist\Uploader;

interface UploaderFilePathAwareInterface
{

public function getFilePath(): string;

}

0 comments on commit fc15b8c

Please sign in to comment.