Skip to content

Commit c346772

Browse files
committed
Fix error when guessing connection name.
Closes #93.
1 parent f9c27fa commit c346772

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/Model/EndpointLocator.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,13 @@ protected function createInstance(string $alias, array $options)
7474
if ($options['className'] !== Endpoint::class) {
7575
$connectionName = $options['className']::defaultConnectionName();
7676
} else {
77-
/** @psalm-suppress PossiblyNullArgument */
78-
$pluginParts = explode('/', pluginSplit($alias)[0]);
79-
80-
$connectionName = Inflector::underscore(end($pluginParts));
77+
if (strpos($alias, '.') === false) {
78+
$connectionName = 'app';
79+
} else {
80+
/** @psalm-suppress PossiblyNullArgument */
81+
$pluginParts = explode('/', pluginSplit($alias)[0]);
82+
$connectionName = Inflector::underscore(end($pluginParts));
83+
}
8184
}
8285

8386
$options['connection'] = $this->getConnection($connectionName);

0 commit comments

Comments
 (0)