Beispiel #1
0
 /**
  * @throws \Exception if one has been queued.
  * @throws \OutOfBoundsException if the queue is empty.
  */
 public function onPrepared(PreparedEvent $event)
 {
     if (!($result = array_shift($this->queue))) {
         throw new \OutOfBoundsException('Result mock queue is empty');
     } elseif ($result instanceof \Exception) {
         throw $result;
     } else {
         $event->intercept($result);
     }
 }
 /**
  * Event to add Segment.io Specific data to the Event Messages
  *
  * @param PreparedEvent $event The PreparedEvent
  *
  * @return bool
  */
 public function onPrepared(PreparedEvent $event)
 {
     $command = $event->getCommand();
     $operation = $this->description->getOperation($command->getName());
     if (!$operation->getData('batching')) {
         return false;
     }
     $parameters = json_decode($event->getRequest()->getBody()->getContents(), true);
     $this->enqueue(array_merge($parameters, ['action' => $command->getName()]));
     $event->intercept(['success' => true, 'batched' => true]);
     return true;
 }