Skip to content

Commit c933324

Browse files
committed
Internal: Migration: Remove stylesheets ad theme settings + move var/theme/* to var/themes - refs BT#21621
1 parent a329033 commit c933324

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?php
2+
3+
namespace Chamilo\CoreBundle\Migrations\Schema\V200;
4+
5+
use Chamilo\CoreBundle\Migrations\AbstractMigrationChamilo;
6+
use Doctrine\DBAL\Schema\Schema;
7+
use Symfony\Component\Filesystem\Filesystem;
8+
use Symfony\Component\Finder\Finder;
9+
10+
class Version20240704185300 extends AbstractMigrationChamilo
11+
{
12+
public function getDescription(): string
13+
{
14+
return "Fix stylesheet and theme settings and move theme directory during development";
15+
}
16+
17+
/**
18+
* @inheritDoc
19+
*/
20+
public function up(Schema $schema): void
21+
{
22+
$this->addSql("DELETE FROM settings_current WHERE variable IN ('stylesheets', 'theme')");
23+
24+
$kernel = $this->container->get('kernel');
25+
$rootPath = $kernel->getProjectDir();
26+
27+
$themeDirectory = $rootPath.'/var/theme';
28+
$themesDirectory = $rootPath.'/var/themes';
29+
30+
$finder = new Finder();
31+
$filesystem = new Filesystem();
32+
33+
$finder->directories()->in($themeDirectory)->depth('== 0');
34+
35+
foreach ($finder as $entry) {
36+
if ($entry->isDir()) {
37+
error_log(
38+
sprintf(
39+
"Moving theme directory: %s %s",
40+
$entry->getRealPath(),
41+
$themesDirectory.'/'
42+
)
43+
);
44+
$filesystem->rename($entry->getRealPath(), $themesDirectory.'/'.$entry->getRelativePathname());
45+
}
46+
}
47+
}
48+
}

0 commit comments

Comments
 (0)