An error occurred while loading the file. Please try again.
-
Guillaume Perréal authoreda73e273c
<?php declare(strict_types=1);
/*
* Copyright (C) 2015-2017 IRSTEA
* All rights reserved.
*/
namespace Irstea\FileUploadBundle\Entity\Repository;
use DateTime;
use Doctrine\ORM\EntityRepository;
use Gaufrette\Filesystem;
use Gaufrette\StreamMode;
use InvalidArgumentException;
use Irstea\FileUploadBundle\Entity\UploadedFile;
use Irstea\FileUploadBundle\Event\FileUploadCompleteEvent;
use Irstea\FileUploadBundle\Exception\RejectedFileException;
use Irstea\FileUploadBundle\FileUploadEvents;
use Irstea\FileUploadBundle\Model\FileManagerInterface;
use Irstea\FileUploadBundle\Model\UploadedFileInterface;
use Psr\Log\LoggerAwareTrait;
use Psr\Log\LogLevel;
use Rhumsaa\Uuid\Uuid;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
/**
* Class UploadedFileRepository.
*/
class UploadedFileRepository extends EntityRepository implements FileManagerInterface
{
use LoggerAwareTrait;
/**
* @var Filesystem
*/
protected $filesystem;
/**
* @var EventDispatcher
*/
protected $eventDispatcher;
/**
* @param Filesystem $filesystem
*/
public function setFilesystem(Filesystem $filesystem)
{
$this->filesystem = $filesystem;
}
/**
* @param EventDispatcherInterface $eventDispatcher
*/
public function setEventDispatcher(EventDispatcherInterface $eventDispatcher)
{
$this->eventDispatcher = $eventDispatcher;
}
/**
* @param string $filename
* @param int $size
* @param string $mimeType
* @param null $lastModified
*
* @return UploadedFile
*/
public function create($filename, $size, $mimeType, $lastModified = null)
{
$file = new UploadedFile();