protected function api_execute($module, $method, $data) { if ($this->auth !== null) { $this->auth->perform($data); } return $this->api->execute($module, $method, $data); }
public function perform(IX4BApiClient $api, &$data) { if (!$this->logged_in) { $resp = $api->execute('User', 'login', array('username' => $this->username, 'password' => $this->password)); if (!$resp || $resp['status'] != 'ok') { throw new ApiAuthorizationException(); } $this->logged_in = true; } }