/
Version20211102171600.php
67 lines (59 loc) · 3.28 KB
/
Version20211102171600.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?php
declare(strict_types=1);
namespace Concrete\Core\Updater\Migrations\Migrations;
use Concrete\Core\Updater\Migrations\RepeatableMigrationInterface;
use Doctrine\DBAL\Schema\Schema;
use Concrete\Core\Updater\Migrations\AbstractMigration;
final class Version20211102171600 extends AbstractMigration implements RepeatableMigrationInterface
{
public function upgradeDatabase()
{
$config = $this->app->make('config');
$sites = $config->get('site.sites');
foreach ($sites as $siteHandle => $configValue) {
$configKey = sprintf('site.sites.%s.editor.ckeditor4.plugins.selected', $siteHandle);
$editorConfig = $config->get($configKey);
$this->output(t('Checking rich text editor settings for site: %s', $siteHandle));
$changed = false;
if ($editorConfig && is_array($editorConfig)) {
$this->output(t('Editor config found.'));
if (($key = array_search('concrete5link', $editorConfig)) !== false) {
$this->output(t(/*i18n: both %s are plugin names*/'Found `%s` plugin in editor config. Updating to `%s`', 'concrete5link', 'concretelink'));
unset($editorConfig[$key]);
$editorConfig[] = 'concretelink';
$changed = true;
}
if (($key = array_search('concrete5filemanager', $editorConfig)) !== false) {
$this->output(t(/*i18n: both %s are plugin names*/'Found `%s` plugin in editor config. Updating to `%s`', 'concrete5filemanager', 'concretefilemanager'));
unset($editorConfig[$key]);
$editorConfig[] = 'concretefilemanager';
$changed = true;
}
if (($key = array_search('concrete5inline', $editorConfig)) !== false) {
$this->output(t(/*i18n: both %s are plugin names*/'Found `%s` plugin in editor config. Updating to `%s`', 'concrete5inline', 'concreteinline'));
unset($editorConfig[$key]);
$editorConfig[] = 'concreteinline';
$changed = true;
}
if (($key = array_search('concrete5styles', $editorConfig)) !== false) {
$this->output(t(/*i18n: both %s are plugin names*/'Found `%s` plugin in editor config. Updating to `%s`', 'concrete5styles', 'concretestyles'));
unset($editorConfig[$key]);
$editorConfig[] = 'concretestyles';
$changed = true;
}
if (($key = array_search('concrete5uploadimage', $editorConfig)) !== false) {
$this->output(t(/*i18n: both %s are plugin names*/'Found `%s` plugin in editor config. Updating to `%s`', 'concrete5uploadimage', 'concreteuploadimage'));
unset($editorConfig[$key]);
$editorConfig[] = 'concreteuploadimage';
$changed = true;
}
if ($changed) {
$this->output(t('Updating config values for new plugins...'));
$config->save($configKey, $editorConfig);
} else {
$this->output(t('No changes to config necessary...'));
}
}
}
}
}