]>
Commit | Line | Data |
---|---|---|
bcf056c9 V |
1 | <?php |
2 | ||
3 | /** | |
4 | * Read the updates file, and return already done updates. | |
5 | * | |
6 | * @param string $updatesFilepath Updates file path. | |
7 | * | |
8 | * @return array Already done update methods. | |
9 | */ | |
10 | function read_updates_file($updatesFilepath) | |
11 | { | |
12 | if (! empty($updatesFilepath) && is_file($updatesFilepath)) { | |
13 | $content = file_get_contents($updatesFilepath); | |
14 | if (! empty($content)) { | |
15 | return explode(';', $content); | |
16 | } | |
17 | } | |
18 | return array(); | |
19 | } | |
20 | ||
21 | /** | |
22 | * Write updates file. | |
23 | * | |
24 | * @param string $updatesFilepath Updates file path. | |
25 | * @param array $updates Updates array to write. | |
26 | * | |
27 | * @throws Exception Couldn't write version number. | |
28 | */ | |
29 | function write_updates_file($updatesFilepath, $updates) | |
30 | { | |
31 | if (empty($updatesFilepath)) { | |
32 | throw new Exception(t('Updates file path is not set, can\'t write updates.')); | |
33 | } | |
34 | ||
35 | $res = file_put_contents($updatesFilepath, implode(';', $updates)); | |
36 | if ($res === false) { | |
37 | throw new Exception(t('Unable to write updates in '. $updatesFilepath . '.')); | |
38 | } | |
39 | } |