private function deliverEvent(EventProcessorFactory $eventFactory, Application $app, array $thirdPartyApplications, WebhookEvent $event) { if (count($thirdPartyApplications) === 0) { $this->log('info', sprintf('No applications defined to listen for webhook events')); return; } // format event data $eventProcessor = $eventFactory->get($event); $data = $eventProcessor->process($event); // batch requests $batch = BatchBuilder::factory()->transferRequests(10)->build(); foreach ($thirdPartyApplications as $thirdPartyApplication) { $delivery = $app['manipulator.webhook-delivery']->create($thirdPartyApplication, $event); // append delivery id as url anchor $uniqueUrl = $this->getUrl($thirdPartyApplication, $delivery); // create http request with data as request body $batch->add($this->httpClient->createRequest('POST', $uniqueUrl, ['Content-Type' => 'application/vnd.phraseanet.event+json'], json_encode($data))); } $batch->flush(); }
/** * @expectedException \RuntimeException */ public function testUnknownProcessor() { $factory = new EventProcessorFactory(self::$DI['app']); $event = new WebhookEvent(); $factory->get($event); }