mirror of
https://github.com/Intervention/image.git
synced 2025-08-28 16:19:50 +02:00
Enable external resolvables
This commit is contained in:
@@ -2,14 +2,21 @@
|
||||
|
||||
namespace Intervention\Image\Drivers;
|
||||
|
||||
use Intervention\Image\Analyzers\AbstractAnalyzer;
|
||||
use Intervention\Image\Encoders\AbstractEncoder;
|
||||
use Intervention\Image\Exceptions\NotSupportedException;
|
||||
use Intervention\Image\Interfaces\DriverInterface;
|
||||
use Intervention\Image\Modifiers\AbstractModifier;
|
||||
use ReflectionClass;
|
||||
|
||||
abstract class AbstractDriver implements DriverInterface
|
||||
{
|
||||
public function resolve(object $input): object
|
||||
{
|
||||
if ($this->isExternal($input)) {
|
||||
return $input;
|
||||
}
|
||||
|
||||
$driver_namespace = (new ReflectionClass($this))->getNamespaceName();
|
||||
$class_path = substr(get_class($input), strlen("Intervention\\Image\\"));
|
||||
$specialized = $driver_namespace . "\\" . $class_path;
|
||||
@@ -22,4 +29,21 @@ abstract class AbstractDriver implements DriverInterface
|
||||
|
||||
return new $specialized($input, $this);
|
||||
}
|
||||
|
||||
private function isExternal(object $input): bool
|
||||
{
|
||||
if ($input instanceof AbstractModifier) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($input instanceof AbstractAnalyzer) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($input instanceof AbstractEncoder) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user