vendor/pimcore/data-hub/src/Migrations/PimcoreX/Version20230503165847.php line 1

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4.  * Pimcore
  5.  *
  6.  * This source file is available under two different licenses:
  7.  * - GNU General Public License version 3 (GPLv3)
  8.  * - Pimcore Commercial License (PCL)
  9.  * Full copyright and license information is available in
  10.  * LICENSE.md which is distributed with this source code.
  11.  *
  12.  *  @copyright  Copyright (c) Pimcore GmbH (http://www.pimcore.org)
  13.  *  @license    http://www.pimcore.org/license     GPLv3 and PCL
  14.  */
  15. namespace Pimcore\Bundle\DataHubBundle\Migrations\PimcoreX;
  16. use Doctrine\DBAL\Schema\Schema;
  17. use Doctrine\Migrations\AbstractMigration;
  18. final class Version20230503165847 extends AbstractMigration
  19. {
  20.     private const CONFIG_DIR PIMCORE_CONFIGURATION_DIRECTORY '/data_hub';
  21.     public function getDescription(): string
  22.     {
  23.         return 'Replace childs with children in symfony configs';
  24.     }
  25.     public function up(Schema $schema): void
  26.     {
  27.         $this->replaceStringInFiles('childs:''children:');
  28.     }
  29.     public function down(Schema $schema): void
  30.     {
  31.         $this->replaceStringInFiles('children:''childs:');
  32.     }
  33.     private function replaceStringInFiles(string $searchstring $replace): void
  34.     {
  35.         if (is_dir(self::CONFIG_DIR)) {
  36.             $files scandir(self::CONFIG_DIR0);
  37.             for ($i 2$i count($files); $i++) {
  38.                 $file self::CONFIG_DIR '/' $files[$i];
  39.                 $fileContent file_get_contents($file);
  40.                 $fileContent str_replace($search$replace$fileContent);
  41.                 file_put_contents($file$fileContent);
  42.             }
  43.         }
  44.     }
  45. }