Skip to content

Commit

Permalink
add methods getError(), getSize() to UploadControlEntity
Browse files Browse the repository at this point in the history
  • Loading branch information
MartkCz committed Jul 20, 2021
1 parent 7880912 commit 7520a6b
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/Bridge/Nette/Form/Entity/UploadControlEntity.php
Expand Up @@ -2,6 +2,7 @@

namespace Contributte\Imagist\Bridge\Nette\Form\Entity;

use Contributte\Imagist\Bridge\Nette\Uploader\FileUploadUploader;
use Contributte\Imagist\Entity\EmptyImageInterface;
use Contributte\Imagist\Entity\PersistentImageInterface;
use Contributte\Imagist\Entity\StorableImageInterface;
Expand All @@ -22,6 +23,26 @@ public function __construct(?StorableImageInterface $value = null, ?PersistentIm
$this->default = $default;
}

public function getSize(): ?int
{
$uploader = $this->value?->getUploader();
if ($uploader instanceof FileUploadUploader) {
return $uploader->getFileUpload()->getSize();
}

return null;
}

public function getError(): ?int
{
$uploader = $this->value?->getUploader();
if ($uploader instanceof FileUploadUploader) {
return $uploader->getFileUpload()->getError();
}

return null;
}

public function getDefault(): ?PersistentImageInterface
{
return $this->default;
Expand Down

0 comments on commit 7520a6b

Please sign in to comment.