From 08ae0df4f0028cadac01882c0cbca862c5166568 Mon Sep 17 00:00:00 2001 From: Oliver Vogel Date: Sun, 26 Nov 2023 11:27:05 +0100 Subject: [PATCH] Enable external resolvables --- src/Drivers/AbstractDriver.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/Drivers/AbstractDriver.php b/src/Drivers/AbstractDriver.php index 5d7bee26..8117f81a 100644 --- a/src/Drivers/AbstractDriver.php +++ b/src/Drivers/AbstractDriver.php @@ -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; + } }