Skip to content

Commit

Permalink
Internal: Migration: Remove stylesheets ad theme settings + move var/…
Browse files Browse the repository at this point in the history
…theme/* to var/themes - refs BT#21621
  • Loading branch information
AngelFQC committed Jul 5, 2024
1 parent a329033 commit c933324
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions src/CoreBundle/Migrations/Schema/V200/Version20240704185300.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php

namespace Chamilo\CoreBundle\Migrations\Schema\V200;

use Chamilo\CoreBundle\Migrations\AbstractMigrationChamilo;
use Doctrine\DBAL\Schema\Schema;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Finder\Finder;

class Version20240704185300 extends AbstractMigrationChamilo
{
public function getDescription(): string
{
return "Fix stylesheet and theme settings and move theme directory during development";
}

/**
* @inheritDoc
*/
public function up(Schema $schema): void
{
$this->addSql("DELETE FROM settings_current WHERE variable IN ('stylesheets', 'theme')");

$kernel = $this->container->get('kernel');
$rootPath = $kernel->getProjectDir();

$themeDirectory = $rootPath.'/var/theme';
$themesDirectory = $rootPath.'/var/themes';

$finder = new Finder();
$filesystem = new Filesystem();

$finder->directories()->in($themeDirectory)->depth('== 0');

foreach ($finder as $entry) {
if ($entry->isDir()) {
error_log(
sprintf(
"Moving theme directory: %s %s",
$entry->getRealPath(),
$themesDirectory.'/'
)
);
$filesystem->rename($entry->getRealPath(), $themesDirectory.'/'.$entry->getRelativePathname());
}
}
}
}

0 comments on commit c933324

Please sign in to comment.