22
33namespace SkautIS ;
44
5+ use SkautIS \Factory \WSFactory ;
6+ use SkautIS \Factory \BasicWSFactory ;
57use SkautIS \Exception \AbortException ;
68use SkautIS \Exception \InvalidArgumentException ;
79use SkautIS \Exception \WsdlException ;
@@ -103,6 +105,11 @@ class SkautIS {
103105 */
104106 public $ profiler ;
105107
108+ /**
109+ * @var WSFactory
110+ */
111+ protected $ wsFactory = NULL ;
112+
106113// </editor-fold>
107114// <editor-fold defaultstate="collapsed" desc="getters & setters">
108115
@@ -201,6 +208,10 @@ public function setStorage(&$storage, $leaveValues = false) {
201208 private function __construct () {
202209 $ this ->perStorage = &$ _SESSION ["__ " . __CLASS__ ]; //defaultni persistentní uloziste
203210
211+ if ($ this ->wsFactory === NULL ) {
212+ $ this ->wsFactory = new BasicWSFactory ();
213+ }
214+
204215 if (defined ("SkautIS_ID_Application " )) {
205216 $ this ->setAppId (SkautIS_ID_Application);
206217 }
@@ -215,7 +226,7 @@ private function __construct() {
215226 * @return SkautIS
216227 * @throws InvalidArgumentException
217228 */
218- public static function getInstance ($ appId = NULL , $ testMode = FALSE , $ profiler = FALSE ) {
229+ public static function getInstance ($ appId = NULL , $ testMode = FALSE , $ profiler = FALSE , $ wsFactory = NULL ) {
219230 if (!is_bool ($ testMode )) {
220231 throw new InvalidArgumentException ('Argument $testMode ma spatnou hodnotu: ' . print_r ($ testMode , TRUE ));
221232 }
@@ -235,6 +246,11 @@ public static function getInstance($appId = NULL, $testMode = FALSE, $profiler =
235246 self ::$ instance ->setTestMode ($ testMode );
236247 self ::$ instance ->profiler = $ profiler ;
237248
249+ if ($ wsFactory !== NULL ) {
250+ self ::$ instance ->wsFactory = $ wsFactory ;
251+ }
252+
253+
238254 return self ::$ instance ;
239255 }
240256
@@ -256,7 +272,7 @@ public function __get($name) {
256272 }
257273
258274 if (!isset ($ this ->active [$ wsdlKey ])) {
259- $ this ->active [$ wsdlKey ] = new WS ($ this ->getWsdlUri ($ wsdlName ), $ this ->perStorage ->init , $ this ->compression , $ this ->profiler );
275+ $ this ->active [$ wsdlKey ] = $ this -> wsFactory -> createWS ($ this ->getWsdlUri ($ wsdlName ), $ this ->perStorage ->init , $ this ->compression , $ this ->profiler );
260276 if ($ this ->profiler ) {
261277 $ this ->active [$ wsdlKey ]->onEvent = $ this ->onEvent ;
262278 }
@@ -372,4 +388,13 @@ public function isMaintenance() {
372388 return FALSE ;
373389 }
374390
391+ /**
392+ * Nastavi WSFactory
393+ *
394+ * @param $wsFactory WSFactory
395+ */
396+ public function setWSFactory (WSFactory $ wsFactory )
397+ {
398+ $ this ->wsFactory = $ wsFactory ;
399+ }
375400}
0 commit comments