/** {@inheritdoc} **/ public function act(EventInterface $event) { if ($event instanceof ErrorEvent) { $ex = new CircuitBreakerException($this->exceptionMessage, 0, $event->getException()); } else { $ex = new CircuitBreakerException($this->exceptionMessage); } throw $ex; }
/** * Deal with OAuth mecanism / exchange user config to a token passport * * @param EventInterface $e * @param $input */ protected function performOAuth(EventInterface $e, $input) { //build request to api oauth $response = $e->getClient()->post($this->getUri($e, '/oauth/token'), ['body' => $input]); //decode response to retrieve token array $token = json_decode($response->getBody()->getContents(), true); //store token $this->storage->store($this->clientId, $token['access_token']); //set token information to header $e->getRequest()->setHeader('Authorization', 'Bearer ' . $token['access_token']); }
/** * Proxies a call to start or end event based on a request event. * * @param string $meth startEvent or endEvent * @param EventInterface $cev Command event * @param EventInterface $rev Request event */ private function proxyReqEvent($meth, EventInterface $cev, EventInterface $rev) { /** @var \GuzzleHttp\Command\Event\AbstractCommandEvent $cev */ /** @noinspection PhpUndefinedMethodInspection */ call_user_func(array($this, $meth), $this->getEventName($rev), $this->hashCommand($cev->getClient(), $cev->getCommand(), $rev), $cev->getCommand(), $rev->getRequest(), method_exists($rev, 'getResponse') ? $rev->getResponse() : null, method_exists($cev, 'getResult') ? $cev->getResult() : null, method_exists($cev, 'getError') ? $cev->getError() : null); }
public function postFoo(EventInterface $e) { $this->postFooInvoked = true; $e->stopPropagation(); }
/** * Proxies a call to start or end event based on a request event. * * @param string $meth startEvent or endEvent * @param EventInterface $cev Command event * @param EventInterface $rev Request event */ private function proxyReqEvent($meth, EventInterface $cev, EventInterface $rev) { call_user_func([$this, $meth], $this->getEventName($rev), $this->hashCommand($cev->getClient(), $cev->getCommand(), $rev), $cev->getCommand(), $rev->getRequest(), method_exists($rev, 'getResponse') ? $rev->getResponse() : null, method_exists($cev, 'getResult') ? $cev->getResult() : null, method_exists($cev, 'getError') ? $cev->getError() : null); }
private function handleErroneousState(EventInterface $event) { $event->stopPropagation(); $this->behaviour->act($event); return false; }