File tree Expand file tree Collapse file tree 1 file changed +48
-0
lines changed
src/CoreBundle/Migrations/Schema/V200 Expand file tree Collapse file tree 1 file changed +48
-0
lines changed Original file line number Diff line number Diff line change
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
+ }
You can’t perform that action at this time.
0 commit comments