Skip to content

Commit

Permalink
fix: Fix bug with custom creators
Browse files Browse the repository at this point in the history
  • Loading branch information
ollieread committed Dec 16, 2024
1 parent c269be6 commit faf71b8
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/Support/BaseFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down

0 comments on commit faf71b8

Please sign in to comment.