Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 19
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 1
PeVersionUpdater
0.00% covered (danger)
0.00%
0 / 19
0.00% covered (danger)
0.00%
0 / 1
12
0.00% covered (danger)
0.00%
0 / 1
 updateDatabase
0.00% covered (danger)
0.00%
0 / 19
0.00% covered (danger)
0.00%
0 / 1
12
1<?php
2
3declare(strict_types=1);
4
5namespace PeServer\App\Models\Domain;
6
7use PeServer\App\Models\Dao\Entities\PeSettingEntityDao;
8use PeServer\App\Models\Dao\Entities\PluginUrlsEntityDao;
9use PeServer\App\Models\Domain\DefaultPlugin;
10use PeServer\App\Models\Domain\PluginUrlKey;
11use PeServer\Core\Database\IDatabaseContext;
12use PeServer\Core\Text;
13
14class PeVersionUpdater
15{
16    #region function
17
18    /**
19     * Undocumented function
20     *
21     * @param IDatabaseContext $context
22     * @param string $baseUrl
23     * @phpstan-param literal-string $baseUrl
24     * @param string $version
25     */
26    public function updateDatabase(IDatabaseContext $context, string $baseUrl, string $version): void
27    {
28        $peSettingEntityDao = new PeSettingEntityDao($context);
29        $peSettingEntityDao->updatePeSettingVersion($version);
30
31        $pluginUrlsEntityDao = new PluginUrlsEntityDao($context);
32
33        $defaultPlugins = DefaultPlugin::get();
34        foreach ($defaultPlugins as $defaultPlugin) {
35            $url = Text::replaceMap(
36                $baseUrl,
37                [
38                    'VERSION' => $version,
39                    'UPDATE_INFO_NAME' => 'update-' . $defaultPlugin->pluginName . '.json',
40                ]
41            );
42
43            // 標準テーマに更新URLは無視
44            if ($defaultPlugin->pluginId === '4524fc23-ebb9-4c79-a26b-8f472c05095e') {
45                $url = '';
46            }
47
48            $pluginUrlsEntityDao->updatePluginUrl(
49                $defaultPlugin->pluginId,
50                PluginUrlKey::CHECK,
51                $url
52            );
53        }
54    }
55
56    #endregion
57}