|
| 1 | +<?php |
| 2 | +/** |
| 3 | + * Copyright © Magento, Inc. All rights reserved. |
| 4 | + * See COPYING.txt for license details. |
| 5 | + */ |
| 6 | +declare(strict_types=1); |
| 7 | + |
| 8 | +namespace Magento\Config\Setup\Patch\Data; |
| 9 | + |
| 10 | +use Magento\Framework\Setup\ModuleDataSetupInterface; |
| 11 | +use Magento\Framework\Setup\Patch\DataPatchInterface; |
| 12 | + |
| 13 | +/** |
| 14 | + * Remove old tinymce versions from the configuration |
| 15 | + */ |
| 16 | +class RemoveTinymceConfig implements DataPatchInterface |
| 17 | +{ |
| 18 | + /** |
| 19 | + * @var ModuleDataSetupInterface |
| 20 | + */ |
| 21 | + private $moduleDataSetup; |
| 22 | + |
| 23 | + /** |
| 24 | + * @param ModuleDataSetupInterface $moduleDataSetup |
| 25 | + */ |
| 26 | + public function __construct( |
| 27 | + ModuleDataSetupInterface $moduleDataSetup |
| 28 | + ) { |
| 29 | + $this->moduleDataSetup = $moduleDataSetup; |
| 30 | + } |
| 31 | + |
| 32 | + /** |
| 33 | + * @inheritdoc |
| 34 | + */ |
| 35 | + public function apply() |
| 36 | + { |
| 37 | + $this->moduleDataSetup->getConnection()->startSetup(); |
| 38 | + |
| 39 | + $select = $this->moduleDataSetup->getConnection()->select() |
| 40 | + ->from( |
| 41 | + $this->moduleDataSetup->getTable('core_config_data'), |
| 42 | + ['value'] |
| 43 | + ) |
| 44 | + ->where('path = ?', 'cms/wysiwyg/editor'); |
| 45 | + |
| 46 | + $configValue = $this->moduleDataSetup->getConnection()->fetchOne($select); |
| 47 | + |
| 48 | + if ($configValue && (strpos($configValue, 'Tinymce3/tinymce3Adapter') !== false |
| 49 | + || strpos($configValue, 'tiny_mce/tinymce4Adapter') !== false) |
| 50 | + ) { |
| 51 | + $this->moduleDataSetup->getConnection()->query( |
| 52 | + $select->deleteFromSelect( |
| 53 | + $this->moduleDataSetup->getTable('core_config_data') |
| 54 | + ) |
| 55 | + ); |
| 56 | + } |
| 57 | + |
| 58 | + return $this->moduleDataSetup->getConnection()->endSetup(); |
| 59 | + } |
| 60 | + |
| 61 | + /** |
| 62 | + * @inheritdoc |
| 63 | + */ |
| 64 | + public static function getDependencies() |
| 65 | + { |
| 66 | + return []; |
| 67 | + } |
| 68 | + |
| 69 | + /** |
| 70 | + * @inheritdoc |
| 71 | + */ |
| 72 | + public function getAliases() |
| 73 | + { |
| 74 | + return []; |
| 75 | + } |
| 76 | +} |
0 commit comments