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 54e6796
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

Check warning on line 20 in src/CoreBundle/Migrations/Schema/V200/Version20240704185300.php

View check run for this annotation

Codecov / codecov/patch

src/CoreBundle/Migrations/Schema/V200/Version20240704185300.php#L20

Added line #L20 was not covered by tests
{
$this->addSql("DELETE FROM settings WHERE variable IN ('stylesheets', 'theme')");

Check warning on line 22 in src/CoreBundle/Migrations/Schema/V200/Version20240704185300.php

View check run for this annotation

Codecov / codecov/patch

src/CoreBundle/Migrations/Schema/V200/Version20240704185300.php#L22

Added line #L22 was not covered by tests

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

Check warning on line 25 in src/CoreBundle/Migrations/Schema/V200/Version20240704185300.php

View check run for this annotation

Codecov / codecov/patch

src/CoreBundle/Migrations/Schema/V200/Version20240704185300.php#L24-L25

Added lines #L24 - L25 were not covered by tests

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

Check warning on line 28 in src/CoreBundle/Migrations/Schema/V200/Version20240704185300.php

View check run for this annotation

Codecov / codecov/patch

src/CoreBundle/Migrations/Schema/V200/Version20240704185300.php#L27-L28

Added lines #L27 - L28 were not covered by tests

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

Check warning on line 31 in src/CoreBundle/Migrations/Schema/V200/Version20240704185300.php

View check run for this annotation

Codecov / codecov/patch

src/CoreBundle/Migrations/Schema/V200/Version20240704185300.php#L30-L31

Added lines #L30 - L31 were not covered by tests

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

Check warning on line 33 in src/CoreBundle/Migrations/Schema/V200/Version20240704185300.php

View check run for this annotation

Codecov / codecov/patch

src/CoreBundle/Migrations/Schema/V200/Version20240704185300.php#L33

Added line #L33 was not covered by tests

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

Check warning on line 42 in src/CoreBundle/Migrations/Schema/V200/Version20240704185300.php

View check run for this annotation

Codecov / codecov/patch

src/CoreBundle/Migrations/Schema/V200/Version20240704185300.php#L35-L42

Added lines #L35 - L42 were not covered by tests
);
$filesystem->rename($entry->getRealPath(), $themesDirectory.'/'.$entry->getRelativePathname());

Check warning on line 44 in src/CoreBundle/Migrations/Schema/V200/Version20240704185300.php

View check run for this annotation

Codecov / codecov/patch

src/CoreBundle/Migrations/Schema/V200/Version20240704185300.php#L44

Added line #L44 was not covered by tests
}
}
}
}

0 comments on commit 54e6796

Please sign in to comment.