init without trunk

This commit is contained in:
Kevin Adametz 2020-07-09 12:49:32 +02:00
parent ed24ac4994
commit bb809e7233
14652 changed files with 177862 additions and 94817 deletions

View file

@ -0,0 +1,15 @@
<?php
namespace Stof\DoctrineExtensionsBundle\Uploadable;
use Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesser;
use Gedmo\Uploadable\MimeType\MimeTypeGuesserInterface;
class MimeTypeGuesserAdapter implements MimeTypeGuesserInterface
{
public function guess($filePath)
{
return MimeTypeGuesser::getInstance()->guess($filePath);
}
}

View file

@ -0,0 +1,47 @@
<?php
namespace Stof\DoctrineExtensionsBundle\Uploadable;
use Symfony\Component\HttpFoundation\File\UploadedFile;
use Gedmo\Uploadable\UploadableListener;
class UploadableManager
{
/** @var \Gedmo\Uploadable\UploadableListener */
private $listener;
private $fileInfoClass;
public function __construct(UploadableListener $listener, $fileInfoClass)
{
$this->listener = $listener;
$this->fileInfoClass = $fileInfoClass;
}
/**
* This method marks an entity to be uploaded as soon as the "flush" method of your object manager is called.
* After calling this method, the file info you passed is set for this entity in the listener. This is all it takes
* to upload a file for an entity in the Uploadable extension.
*
* @param object $entity - The entity you are marking to "Upload" as soon as you call "flush".
* @param mixed $fileInfo - The file info object or array. In Symfony 2, this will be typically an UploadedFile instance.
*/
public function markEntityToUpload($entity, $fileInfo)
{
if (is_object($fileInfo) && $fileInfo instanceof UploadedFile) {
$fileInfoClass = $this->fileInfoClass;
$fileInfo = new $fileInfoClass($fileInfo);
}
$this->listener->addEntityFileInfo($entity, $fileInfo);
}
/**
* @return \Gedmo\Uploadable\UploadableListener
*/
public function getUploadableListener()
{
return $this->listener;
}
}

View file

@ -0,0 +1,49 @@
<?php
namespace Stof\DoctrineExtensionsBundle\Uploadable;
use Gedmo\Uploadable\FileInfo\FileInfoInterface;
use Symfony\Component\HttpFoundation\File\UploadedFile;
class UploadedFileInfo implements FileInfoInterface
{
private $uploadedFile;
public function __construct(UploadedFile $uploadedFile)
{
$this->uploadedFile = $uploadedFile;
}
public function getTmpName()
{
return $this->uploadedFile->getPathname();
}
public function getName()
{
return $this->uploadedFile->getClientOriginalName();
}
public function getSize()
{
return $this->uploadedFile->getClientSize();
}
public function getType()
{
return $this->uploadedFile->getMimeType();
}
public function getError()
{
return $this->uploadedFile->getError();
}
/**
* {@inheritDoc}
*/
public function isUploadedFile()
{
return is_uploaded_file($this->uploadedFile->getPathname());
}
}