@@ -29,6 +29,13 @@ abstract class MultipleInstanceManager
2929 */
3030 protected $ customCreators = [];
3131
32+ /**
33+ * The key name of the "driver" equivalent configuration option.
34+ *
35+ * @var string
36+ */
37+ protected $ driverKey = 'driver ' ;
38+
3239 /**
3340 * Create a new manager instance.
3441 *
@@ -104,19 +111,19 @@ protected function resolve($name)
104111 throw new InvalidArgumentException ("Instance [ {$ name }] is not defined. " );
105112 }
106113
107- if (! array_key_exists (' driver ' , $ config )) {
108- throw new RuntimeException ("Instance [ {$ name }] does not specify a driver . " );
114+ if (! array_key_exists ($ this -> driverKey , $ config )) {
115+ throw new RuntimeException ("Instance [ {$ name }] does not specify a { $ this -> driverKey } . " );
109116 }
110117
111- if (isset ($ this ->customCreators [$ config [' driver ' ]])) {
118+ if (isset ($ this ->customCreators [$ config [$ this -> driverKey ]])) {
112119 return $ this ->callCustomCreator ($ config );
113120 } else {
114- $ driverMethod = 'create ' .ucfirst ($ config [' driver ' ]).' Driver ' ;
121+ $ createMethod = 'create ' .ucfirst ($ config [$ this -> driverKey ]).ucfirst ( $ this -> driverKey ) ;
115122
116- if (method_exists ($ this , $ driverMethod )) {
117- return $ this ->{$ driverMethod }($ config );
123+ if (method_exists ($ this , $ createMethod )) {
124+ return $ this ->{$ createMethod }($ config );
118125 } else {
119- throw new InvalidArgumentException ("Instance driver [ {$ config [' driver ' ]}] is not supported. " );
126+ throw new InvalidArgumentException ("Instance { $ this -> driverKey } [ {$ config [$ this -> driverKey ]}] is not supported. " );
120127 }
121128 }
122129 }
@@ -129,7 +136,7 @@ protected function resolve($name)
129136 */
130137 protected function callCustomCreator (array $ config )
131138 {
132- return $ this ->customCreators [$ config [' driver ' ]]($ this ->app , $ config );
139+ return $ this ->customCreators [$ config [$ this -> driverKey ]]($ this ->app , $ config );
133140 }
134141
135142 /**
0 commit comments