/** * construct controller object * * @param none * @return none */ public function __construct() { /* start preparing the virgin soap message */ $this->soapMessage = array(); $this->soapMessage['request'] = array(); /* initialize a logger object */ $this->logger = betfairLogger::getInstance(); /* set up the Soap dialoge */ $this->prepareDialogue(); // If I have a sessionToken cached, skip the login $sessionTokenCache = betfairCache::fetch('sessionToken'); if (FALSE == $sessionTokenCache) { /* otherwise, log this controller in before we do anything else */ $loginresult = $this->login(); $sessionToken = $loginresult->Result->header->sessionToken; $this->dialogue->setSessionToken($sessionToken); } /* at this point, I have either logged in and retrieved a sesssion, or I have a sessionToken * in cache and so will add it to the soap message in the contructRequest method. * * @TODO The betfairDialogue should be extended * to check for session expiries in all responses and purge the sessionToken cache element, which * would then force a re-login when this controller gets reinstantiated */ }
public static function getInstance() { if (!isset(self::$instance)) { $c = __CLASS__; self::$instance = new $c(); } return self::$instance; }
protected function setUp() { $this->logger = betfairLogger::getInstance(); $this->message = "\nthis is a test " . rand(); }
/** * Perform an operation against whichever betfair exchange hosts the current context/method * Also grab the session token returned in the soap header and store it for reuse * * @return result object from soap client */ public function execute() { /* which interface does this method live in? */ if (true === in_array($this->context, $this->globalMethods)) { $this->activeClient = $this->globalClient; } else { if (true === in_array($this->context, $this->exchangeMethods)) { $this->activeClient = $this->exchangeClient; } else { betfairLogger::log('invalid method: ' . $this->context . ' passed'); die; } } try { $method = $this->context; $res = $this->activeClient->{$method}($this->data); } catch (SoapFault $fault) { $this->handleError($fault); } /** assign session token to this dialogue's $sessionToken */ $this->setSessionToken($res->Result->header->sessionToken); return $res; }
public function __construct() { $this->logger = betfairLogger::getInstance(); }