PluginProbe
Sendy / trunk
Sendy vtrunk
3.4.6 3.4.7 trunk 3.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.2 3.1.3 3.2.0 3.2.1 3.2.2 3.2.3 3.2.4 3.2.5 3.2.6 3.2.7 All 32 releases
sendy / lib / Repositories / Shops.php

Shops.php in Sendy trunk, at lib/Repositories/Shops.php

35 lines 825 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Sendy\WooCommerce\Repositories;
4
5 class Shops extends Repository
6 {
7 /**
8 * Returns a map of shops
9 *
10 * The shops are stored in the transient for the duration of one hour. The results from the API are transformed to
11 * a map of shops with the UUID as key and the name as value.
12 *
13 * @throws \GuzzleHttp\Exception\GuzzleException
14 * @throws \Sendy\Api\ApiException
15 */
16 public function list(): array
17 {
18 $shops = get_transient('sendy_shops');
19
20 if (! $shops) {
21 $result = $this->connection()->shop->list();
22
23 $shops = [];
24
25 foreach ($result as $shop) {
26 $shops[$shop['uuid']] = $shop['name'];
27 }
28
29 set_transient('sendy_shops', $shops, 3600);
30 }
31
32 return $shops;
33 }
34 }
35