Spamworldpro Mini Shell
Spamworldpro


Server : Apache
System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64
User : corals ( 1002)
PHP Version : 7.4.33
Disable Function : exec,passthru,shell_exec,system
Directory :  /home/corals/cartforge.co/vendor/magento/module-page-builder/Setup/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/cartforge.co/vendor/magento/module-page-builder/Setup/UpgradeContentHelper.php
<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
namespace Magento\PageBuilder\Setup;

use Magento\Framework\DB\AggregatedFieldDataConverter;
use Magento\Framework\DB\FieldDataConversionException;
use Magento\Framework\DB\FieldToConvert;
use Magento\Framework\DB\Select\QueryModifierFactory;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\PageBuilder\Model\UpgradableEntitiesPool;

/**
 * Helper class to run collection of converters
 */
class UpgradeContentHelper
{
    public const PAGE_BUILDER_CONTENT_PATTERN = '%data-content-type="%';

    /**
     * @var ModuleDataSetupInterface $moduleDataSetup
     */
    private $moduleDataSetup;

    /**
     * @var QueryModifierFactory
     */
    private $queryModifierFactory;

    /**
     * @var UpgradableEntitiesPool
     */
    private $entitiesPool;

    /**
     * @var AggregatedFieldDataConverter
     */
    private $aggregatedFieldDataConverter;

    /**
     * UpgradeContentHelper constructor.
     *
     * @param ModuleDataSetupInterface $moduleDataSetup
     * @param QueryModifierFactory $queryModifierFactory
     * @param UpgradableEntitiesPool $entitiesPool
     * @param AggregatedFieldDataConverter $aggregatedFieldDataConverter
     */
    public function __construct(
        ModuleDataSetupInterface $moduleDataSetup,
        QueryModifierFactory $queryModifierFactory,
        UpgradableEntitiesPool $entitiesPool,
        AggregatedFieldDataConverter $aggregatedFieldDataConverter
    ) {
        $this->moduleDataSetup = $moduleDataSetup;
        $this->queryModifierFactory = $queryModifierFactory;
        $this->entitiesPool = $entitiesPool;
        $this->aggregatedFieldDataConverter = $aggregatedFieldDataConverter;
    }

    /**
     * Executes each specified converter against all upgradable fields in the database
     *
     * @param array $converters
     * @throws FieldDataConversionException
     */
    public function upgrade(array $converters): void
    {
        if (count($converters)) {
            $fields = [];

            foreach ($this->entitiesPool->getEntities() as $tableName => $tableInfo) {
                foreach ($tableInfo['fields'] as $fieldName => $upgradeField) {
                    if (!$upgradeField) {
                        continue;
                    }

                    $queryModifier = $this->queryModifierFactory->create(
                        'like',
                        [
                            'values' => [
                                $fieldName => self::PAGE_BUILDER_CONTENT_PATTERN
                            ]
                        ]
                    );

                    foreach ($converters as $converter) {
                        $fields[] = new FieldToConvert(
                            $converter,
                            $this->moduleDataSetup->getTable($tableName),
                            $tableInfo['identifier'],
                            $fieldName,
                            $queryModifier
                        );
                    }

                }
            }

            $this->aggregatedFieldDataConverter->convert($fields, $this->moduleDataSetup->getConnection());
        }
    }
}

Spamworldpro Mini