mirror of
https://github.com/Intervention/image.git
synced 2025-08-14 01:44:03 +02:00
added coreAvailable() method to drivers
This commit is contained in:
@@ -35,6 +35,13 @@ abstract class AbstractDriver
|
||||
* @return AbstractColor
|
||||
*/
|
||||
abstract public function parseColor($value);
|
||||
|
||||
/**
|
||||
* Checks if core module installation is available
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
abstract protected function coreAvailable();
|
||||
|
||||
/**
|
||||
* Initiates new image from given input
|
||||
|
@@ -14,6 +14,12 @@ class Driver extends \Intervention\Image\AbstractDriver
|
||||
*/
|
||||
public function __construct(Source $source = null, Encoder $encoder = null)
|
||||
{
|
||||
if ( ! $this->coreAvailable()) {
|
||||
throw new \Intervention\Image\Exception\NotSupportedException(
|
||||
"GD Library extension not available with this PHP installation."
|
||||
);
|
||||
}
|
||||
|
||||
$this->source = $source ? $source : new Source;
|
||||
$this->encoder = $encoder ? $encoder : new Encoder;
|
||||
}
|
||||
@@ -50,4 +56,14 @@ class Driver extends \Intervention\Image\AbstractDriver
|
||||
{
|
||||
return new Color($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if core module installation is available
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
protected function coreAvailable()
|
||||
{
|
||||
return (extension_loaded('gd') && function_exists('gd_info'));
|
||||
}
|
||||
}
|
||||
|
@@ -14,6 +14,12 @@ class Driver extends \Intervention\Image\AbstractDriver
|
||||
*/
|
||||
public function __construct(Source $source = null, Encoder $encoder = null)
|
||||
{
|
||||
if ( ! $this->coreAvailable()) {
|
||||
throw new \Intervention\Image\Exception\NotSupportedException(
|
||||
"ImageMagick module not available with this PHP installation."
|
||||
);
|
||||
}
|
||||
|
||||
$this->source = $source ? $source : new Source;
|
||||
$this->encoder = $encoder ? $encoder : new Encoder;
|
||||
}
|
||||
@@ -56,4 +62,14 @@ class Driver extends \Intervention\Image\AbstractDriver
|
||||
{
|
||||
return new Color($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if core module installation is available
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
protected function coreAvailable()
|
||||
{
|
||||
return (extension_loaded('imagick') && class_exists('Imagick'));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user