ソースを参照

Fix aliasing in ConnectionManager

You should be able to alias a connection that does not exist to one
that does.
mark_story 12 年 前
コミット
ef89ebba51
1 ファイル変更4 行追加10 行削除
  1. 4 10
      Cake/Database/ConnectionManager.php

+ 4 - 10
Cake/Database/ConnectionManager.php

@@ -91,20 +91,14 @@ class ConnectionManager {
  *
  * You can remove aliases with ConnectionManager::dropAlias().
  *
- * @param string|array $from The connection to rename. Can also be a map of multiple
- *   aliases to set.
- * @param string $to The connection $from should return when loaded with get().
+ * @param string $from The connection to add an alias to.
+ * @param string $to The alias to create. $from should return when loaded with get().
  * @return void
  */
 	public static function alias($from, $to = null) {
-		if (is_array($from)) {
-			foreach ($from as $source => $dest) {
-				static::alias($source, $dest);
-			}
-		}
-		if (empty(static::$_config[$from])) {
+		if (empty(static::$_config[$to]) && empty(static::$_config[$from])) {
 			throw new Error\MissingDatasourceConfigException(
-				__d('cake_dev', 'Cannot alias connection "%s" as it does not exist.', $from)
+				__d('cake_dev', 'Cannot create alias of "%s" as it does not exist.', $from)
 			);
 		}
 		static::$_aliasMap[$to] = $from;