diff --git a/src/Support/BaseFactory.php b/src/Support/BaseFactory.php index d2dd4e2..448ec2e 100644 --- a/src/Support/BaseFactory.php +++ b/src/Support/BaseFactory.php @@ -186,15 +186,22 @@ protected function resolve(string $name): object } // Ooo custom creation logic, let's use that - if (isset($this->customCreators[$name])) { + if (isset(static::$customCreators[$name])) { return $this->callCustomCreator($name, $config); } + /** @var string|null $driver */ + $driver = $config['driver'] ?? null; + // Is there a driver? - if (isset($config['driver'])) { + if ($driver !== null) { + // Is there a custom creator for the driver? + if (isset(static::$customCreators[$driver])) { + return $this->callCustomCreator($driver, $config); + } + // This has a driver, so we'll see if we can create based on that - /** @phpstan-ignore-next-line */ - $method = 'create' . ucfirst($config['driver']) . ucfirst($this->getFactoryName()); + $method = 'create' . ucfirst($driver) . ucfirst($this->getFactoryName()); } else { // There's no driver, so we'll see if there's a default available $method = 'createDefault' . ucfirst($this->getFactoryName());