← All changes
|
vendor/wpfluent/framework/src/WPFluent/Database/ConnectionResolver.php
+4
-3
1.22
→
2.1.0
View file →
| @@ -1,8 +1,9 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | namespace FluentBoards\Framework\Database; |
| 4 | 4 | |
| 5 | +use InvalidArgumentException; | |
| 5 | 6 | use FluentBoards\Framework\Foundation\App; |
| 6 | 7 | use FluentBoards\Framework\Database\ConnectionResolverInterface; |
| 7 | 8 | |
| 8 | 9 | class ConnectionResolver implements ConnectionResolverInterface |
| @@ -46,9 +47,9 @@ | ||
| 46 | 47 | return $name; |
| 47 | 48 | } |
| 48 | 49 | |
| 49 | 50 | if (is_null($name)) { |
| 50 | - return $this->getDefaultConnection(); | |
| 51 | + $name = $this->getDefaultConnection(); | |
| 51 | 52 | } |
| 52 | 53 | |
| 53 | 54 | if (isset($this->connections[$name])) { |
| 54 | 55 | return $this->connections[$name]; |
| @@ -53,9 +54,9 @@ | ||
| 53 | 54 | if (isset($this->connections[$name])) { |
| 54 | 55 | return $this->connections[$name]; |
| 55 | 56 | } |
| 56 | 57 | |
| 57 | - return $this->getDefaultConnection(); | |
| 58 | + throw new InvalidArgumentException("Connection [{$name}] not found."); | |
| 58 | 59 | } |
| 59 | 60 | |
| 60 | 61 | /** |
| 61 | 62 | * Add a connection to the resolver. |
| @@ -86,9 +87,9 @@ | ||
| 86 | 87 | * @return string |
| 87 | 88 | */ |
| 88 | 89 | public function getDefaultConnection() |
| 89 | 90 | { |
| 90 | - return $this->default ?: App::getInstance('db'); | |
| 91 | + return $this->default; | |
| 91 | 92 | } |
| 92 | 93 | |
| 93 | 94 | /** |
| 94 | 95 | * Set the default connection name. |