Skip to content

Commit d8482ab

Browse files
committed
DRYed up the forge connection command.
1 parent 2d541f0 commit d8482ab

1 file changed

Lines changed: 1 addition & 38 deletions

File tree

system/Database/Config.php

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -141,44 +141,7 @@ public static function getConnections()
141141
*/
142142
public static function forge($group = null)
143143
{
144-
// Allow custom connections to be sent in
145-
if (is_array($group))
146-
{
147-
$config = $group;
148-
$group = 'custom-' . md5(json_encode($config));
149-
}
150-
else
151-
{
152-
$config = config('Database');
153-
}
154-
155-
static::ensureFactory();
156-
157-
if (empty($group))
158-
{
159-
$group = ENVIRONMENT === 'testing' ? 'tests' : $config->defaultGroup;
160-
}
161-
162-
if (is_string($group) && ! isset($config->$group) && ! is_array($config))
163-
{
164-
throw new \InvalidArgumentException($group . ' is not a valid database connection group.');
165-
}
166-
167-
if (! isset(static::$instances[$group]))
168-
{
169-
if (is_array($config))
170-
{
171-
$db = static::connect($config);
172-
}
173-
else
174-
{
175-
$db = static::connect($group);
176-
}
177-
}
178-
else
179-
{
180-
$db = static::$instances[$group];
181-
}
144+
$db = static::connect($group);
182145

183146
return static::$factory->loadForge($db);
184147
}

0 commit comments

Comments
 (0)