mirror of
https://github.com/Intervention/image.git
synced 2025-01-17 12:18:14 +01:00
Merge pull request #668 from frederikbosch/own-driver
allow intervention to use own drivers
This commit is contained in:
commit
2ab7e97d08
@ -100,15 +100,25 @@ class ImageManager
|
||||
*/
|
||||
private function createDriver()
|
||||
{
|
||||
$drivername = ucfirst($this->config['driver']);
|
||||
$driverclass = sprintf('Intervention\\Image\\%s\\Driver', $drivername);
|
||||
if (is_string($this->config['driver'])) {
|
||||
$drivername = ucfirst($this->config['driver']);
|
||||
$driverclass = sprintf('Intervention\\Image\\%s\\Driver', $drivername);
|
||||
|
||||
if (class_exists($driverclass)) {
|
||||
return new $driverclass;
|
||||
if (class_exists($driverclass)) {
|
||||
return new $driverclass;
|
||||
}
|
||||
|
||||
throw new \Intervention\Image\Exception\NotSupportedException(
|
||||
"Driver ({$drivername}) could not be instantiated."
|
||||
);
|
||||
}
|
||||
|
||||
if ($this->config['driver'] instanceof AbstractDriver) {
|
||||
return $this->config['driver'];
|
||||
}
|
||||
|
||||
throw new \Intervention\Image\Exception\NotSupportedException(
|
||||
"Driver ({$drivername}) could not be instantiated."
|
||||
"Unknown driver type."
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -26,4 +26,14 @@ class ImageManagerTest extends PHPUnit_Framework_TestCase
|
||||
$this->assertEquals('foo', $manager->config['driver']);
|
||||
$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());
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user