/** * Helper function that returns the CloudApiAuthPlugin listener. * * @param \Acquia\Cloud\Api\CloudApiClient $cloudapi * * @return \Acquia\Cloud\Api\CloudApiAuthPlugin * * @throws \UnexpectedValueException */ public function getRegisteredAuthPlugin(CloudApiClient $cloudapi) { $listeners = $cloudapi->getEventDispatcher()->getListeners('request.before_send'); foreach ($listeners as $listener) { if (isset($listener[0]) && $listener[0] instanceof CloudApiAuthPlugin) { return $listener[0]; } } throw new \UnexpectedValueException('Expecting subscriber Acquia\\Cloud\\Api\\CloudApiAuthPlugin to be registered'); }