-
Notifications
You must be signed in to change notification settings - Fork 486
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Internal: Migration: Remove stylesheets ad theme settings + move var/…
…theme/* to var/themes - refs BT#21621
- Loading branch information
Showing
1 changed file
with
48 additions
and
0 deletions.
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
src/CoreBundle/Migrations/Schema/V200/Version20240704185300.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 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()); | ||
} | ||
} | ||
} | ||
} |