mirror of
https://github.com/Intervention/image.git
synced 2025-08-09 15:26:38 +02:00
allow decoding directly from upload object
This commit is contained in:
@@ -87,6 +87,16 @@ abstract class AbstractDecoder
|
|||||||
return is_a($this->data, '\Intervention\Image\Image');
|
return is_a($this->data, '\Intervention\Image\Image');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determines if current data is Symfony UploadedFile component
|
||||||
|
*
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public function isSymfonyUpload()
|
||||||
|
{
|
||||||
|
return is_a($this->data, 'Symfony\Component\HttpFoundation\File\UploadedFile');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines if current source data is file path
|
* Determines if current source data is file path
|
||||||
*
|
*
|
||||||
@@ -161,6 +171,10 @@ abstract class AbstractDecoder
|
|||||||
return $this->initFromInterventionImage($this->data);
|
return $this->initFromInterventionImage($this->data);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case $this->isSymfonyUpload():
|
||||||
|
return $this->initFromPath($this->data->getRealPath());
|
||||||
|
break;
|
||||||
|
|
||||||
case $this->isBinary():
|
case $this->isBinary():
|
||||||
return $this->initFromBinary($this->data);
|
return $this->initFromBinary($this->data);
|
||||||
break;
|
break;
|
||||||
|
@@ -89,6 +89,16 @@ class AbstractDecoderTest extends PHPUnit_Framework_TestCase
|
|||||||
$this->assertTrue($source->isInterventionImage());
|
$this->assertTrue($source->isInterventionImage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testIsSymfonyUpload()
|
||||||
|
{
|
||||||
|
$source = $this->getTestDecoder(1);
|
||||||
|
$this->assertFalse($source->isSymfonyUpload());
|
||||||
|
|
||||||
|
$img = Mockery::mock('Symfony\Component\HttpFoundation\File\UploadedFile');
|
||||||
|
$source = $this->getTestDecoder($img);
|
||||||
|
$this->assertTrue($source->isSymfonyUpload());
|
||||||
|
}
|
||||||
|
|
||||||
public function getTestDecoder($data)
|
public function getTestDecoder($data)
|
||||||
{
|
{
|
||||||
return $this->getMockForAbstractClass('\Intervention\Image\AbstractDecoder', array($data));
|
return $this->getMockForAbstractClass('\Intervention\Image\AbstractDecoder', array($data));
|
||||||
|
Reference in New Issue
Block a user