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