private function getOAuth2Adapter($adapter_id, $state = null) { if (empty($adapter_id)) { return null; } try { $adapter = OAuth2::getAdapterInstance($adapter_id); $adapter->setState($state); return $adapter; } catch (OAuth2_Exception $ex) { $this->logException($ex); return null; } }