@@ 44-56 (lines=13) @@ | ||
41 | * @param Host[] $hosts |
|
42 | * @throws Exception |
|
43 | */ |
|
44 | public static function load(...$hosts) |
|
45 | { |
|
46 | $hosts = array_flatten($hosts); |
|
47 | foreach ($hosts as $host) { |
|
48 | $collection = $host->getConfig()->getCollection(); |
|
49 | ||
50 | if ($collection instanceof PersistentCollection) { |
|
51 | $collection->load(); |
|
52 | } else { |
|
53 | throw new Exception("Can't load data for `$host` host. Host doesn't persistent."); |
|
54 | } |
|
55 | } |
|
56 | } |
|
57 | ||
58 | /** |
|
59 | * @param Host[] $hosts |
|
@@ 62-74 (lines=13) @@ | ||
59 | * @param Host[] $hosts |
|
60 | * @throws Exception |
|
61 | */ |
|
62 | public static function flush(...$hosts) |
|
63 | { |
|
64 | $hosts = array_flatten($hosts); |
|
65 | foreach ($hosts as $host) { |
|
66 | $collection = $host->getConfig()->getCollection(); |
|
67 | ||
68 | if ($collection instanceof PersistentCollection) { |
|
69 | $collection->flush(); |
|
70 | } else { |
|
71 | throw new Exception("Can't load data for `$host` host. Host doesn't persistent."); |
|
72 | } |
|
73 | } |
|
74 | } |
|
75 | ||
76 | /** |
|
77 | * @param Host $host |