| Conditions | 4 |
| Paths | 4 |
| Total Lines | 28 |
| Code Lines | 16 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 1 | Features | 0 |
| 1 | <?php |
||
| 33 | public function createWebhooks(string $storeName, array $topics) |
||
| 34 | { |
||
| 35 | $api = $this->apis->getForStore($storeName); |
||
| 36 | |||
| 37 | $existing = $api->Webhook->findAll(); |
||
| 38 | |||
| 39 | foreach ($topics as $topic) { |
||
| 40 | foreach ($existing as $ex) { |
||
| 41 | if ($ex['topic'] == $topic) { |
||
| 42 | continue 2; |
||
| 43 | } |
||
| 44 | } |
||
| 45 | |||
| 46 | $endpoint = $this->router->generate('codecloud_shopify_webhooks', [ |
||
| 47 | 'store' => $storeName, |
||
| 48 | 'topic' => $topic, |
||
| 49 | ], UrlGeneratorInterface::ABSOLUTE_URL); |
||
| 50 | |||
| 51 | // endpoint HAS to be https |
||
| 52 | $endpoint = str_replace("http://", "https://", $endpoint); |
||
| 53 | |||
| 54 | $webhook = GenericResource::create([ |
||
| 55 | 'topic' => $topic, |
||
| 56 | 'address' => $endpoint, |
||
| 57 | 'format' => 'json', |
||
| 58 | ]); |
||
| 59 | |||
| 60 | $api->Webhook->create($webhook); |
||
| 61 | } |
||
| 64 |