@@ -23,18 +23,22 @@ class SzamlaAgentAPI extends SzamlaAgent {
2323 * @return SzamlaAgent
2424 * @throws SzamlaAgentException
2525 */
26- public static function create ($ apiKey , $ downloadPdf = true , $ logLevel = Log::LOG_LEVEL_DEBUG , $ responseType = SzamlaAgentResponse::RESULT_AS_TEXT , $ aggregator = '' ) {
27- $ index = self ::getHash ($ apiKey );
26+ public static function create ($ apiKey , $ downloadPdf = true , $ logLevel = Log::LOG_LEVEL_DEBUG , $ responseType = SzamlaAgentResponse::RESULT_AS_TEXT , $ aggregator = '' , $ singleton = true ) {
2827
2928 $ agent = null ;
30- if (isset (self ::$ agents [$ index ])) {
31- $ agent = self ::$ agents [$ index ];
32- }
3329
34- if ($ agent === null ) {
35- return self ::$ agents [$ index ] = new self (null , null , $ apiKey , $ downloadPdf , $ logLevel , $ responseType , $ aggregator );
30+ if ($ singleton ) {
31+ $ index = self ::getHash ($ apiKey );
32+ if (isset (self ::$ agents [$ index ])) {
33+ $ agent = self ::$ agents [$ index ];
34+ } else {
35+ $ agent = new self (null , null , $ apiKey , $ downloadPdf , $ logLevel , $ responseType , $ aggregator );
36+ self ::$ agents [$ index ] = $ agent ;
37+ }
3638 } else {
37- return $ agent ;
39+ $ agent = new self (null , null , $ apiKey , $ downloadPdf , $ logLevel , $ responseType , $ aggregator );
40+ $ agent ->setSingleton ($ singleton );
3841 }
42+ return $ agent ;
3943 }
4044}
0 commit comments