mirror of
https://github.com/Intervention/image.git
synced 2025-08-10 16:04:04 +02:00
Merge pull request #668 from frederikbosch/own-driver
allow intervention to use own drivers
This commit is contained in:
@@ -100,6 +100,7 @@ class ImageManager
|
|||||||
*/
|
*/
|
||||||
private function createDriver()
|
private function createDriver()
|
||||||
{
|
{
|
||||||
|
if (is_string($this->config['driver'])) {
|
||||||
$drivername = ucfirst($this->config['driver']);
|
$drivername = ucfirst($this->config['driver']);
|
||||||
$driverclass = sprintf('Intervention\\Image\\%s\\Driver', $drivername);
|
$driverclass = sprintf('Intervention\\Image\\%s\\Driver', $drivername);
|
||||||
|
|
||||||
@@ -112,6 +113,15 @@ class ImageManager
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($this->config['driver'] instanceof AbstractDriver) {
|
||||||
|
return $this->config['driver'];
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new \Intervention\Image\Exception\NotSupportedException(
|
||||||
|
"Unknown driver type."
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if all requirements are available
|
* Check if all requirements are available
|
||||||
*
|
*
|
||||||
|
@@ -26,4 +26,14 @@ class ImageManagerTest extends PHPUnit_Framework_TestCase
|
|||||||
$this->assertEquals('foo', $manager->config['driver']);
|
$this->assertEquals('foo', $manager->config['driver']);
|
||||||
$this->assertEquals('baz', $manager->config['bar']);
|
$this->assertEquals('baz', $manager->config['bar']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testConfigureObject()
|
||||||
|
{
|
||||||
|
$config = array('driver' => new Intervention\Image\Imagick\Driver());
|
||||||
|
$manager = new ImageManager($config);
|
||||||
|
|
||||||
|
$image = $manager->make('data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7');
|
||||||
|
$this->assertInstanceOf('Intervention\Image\Image', $image);
|
||||||
|
$this->assertInstanceOf('Imagick', $image->getCore());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user