Skip to content

Commit 669afbc

Browse files
Merge branch 'tmp-colors' into christian/colors
2 parents af50648 + 49d1c7d commit 669afbc

File tree

2 files changed

+93
-0
lines changed

2 files changed

+93
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/* For licensing terms, see /license.txt */
6+
7+
namespace Chamilo\CoreBundle\DataFixtures;
8+
9+
use Chamilo\CoreBundle\Entity\ColorTheme;
10+
use Doctrine\Bundle\FixturesBundle\Fixture;
11+
use Doctrine\Persistence\ObjectManager;
12+
13+
class ColorThemeFixtures extends Fixture
14+
{
15+
public function load(ObjectManager $manager): void
16+
{
17+
$date = api_get_utc_datetime(null, false, true);
18+
$json = '{"--color-primary-base":"46 117 163","--color-primary-gradient":"-1 86 130","--color-primary-button-text":"46 117 163","--color-primary-button-alternative-text":"255 255 255","--color-secondary-base":"243 126 47","--color-secondary-gradient":"193 81 -31","--color-secondary-button-text":"255 255 255","--color-tertiary-base":"51 51 51","--color-tertiary-gradient":"103 103 103","--color-tertiary-button-text":"51 51 51","--color-success-base":"119 170 12","--color-success-gradient":"80 128 -43","--color-success-button-text":"255 255 255","--color-info-base":"13 123 253","--color-info-gradient":"-33 83 211","--color-info-button-text":"255 255 255","--color-warning-base":"245 206 1","--color-warning-gradient":"189 151 -65","--color-warning-button-text":"0 0 0","--color-danger-base":"223 59 59","--color-danger-gradient":"180 -13 20","--color-danger-button-text":"255 255 255","--color-form-base":"46 117 163"}';
19+
20+
// @todo check if we still need skill_rel_skill
21+
$theme = (new ColorTheme())
22+
->setTitle('Chamilo')
23+
->setSlug('chamilo')
24+
->setVariables([$json])
25+
->setCreatedAt($date)
26+
->setUpdatedAt($date)
27+
;
28+
$manager->persist($theme);
29+
30+
$manager->flush();
31+
}
32+
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<?php
2+
3+
/* For licensing terms, see /license.txt */
4+
5+
declare(strict_types=1);
6+
7+
namespace Chamilo\CoreBundle\Migrations\Schema\V200;
8+
9+
use Chamilo\CoreBundle\Migrations\AbstractMigrationChamilo;
10+
use Doctrine\DBAL\Schema\Schema;
11+
12+
final class Version20250709170000 extends AbstractMigrationChamilo
13+
{
14+
public function getDescription(): string
15+
{
16+
return 'Add default Chamilo CSS theme';
17+
}
18+
19+
public function up(Schema $schema): void
20+
{
21+
// Check if template already exists
22+
$name = 'chamilo';
23+
$json = '{"--color-primary-base":"46 117 163","--color-primary-gradient":"-1 86 130","--color-primary-button-text":"46 117 163","--color-primary-button-alternative-text":"255 255 255","--color-secondary-base":"243 126 47","--color-secondary-gradient":"193 81 -31","--color-secondary-button-text":"255 255 255","--color-tertiary-base":"51 51 51","--color-tertiary-gradient":"103 103 103","--color-tertiary-button-text":"51 51 51","--color-success-base":"119 170 12","--color-success-gradient":"80 128 -43","--color-success-button-text":"255 255 255","--color-info-base":"13 123 253","--color-info-gradient":"-33 83 211","--color-info-button-text":"255 255 255","--color-warning-base":"245 206 1","--color-warning-gradient":"189 151 -65","--color-warning-button-text":"0 0 0","--color-danger-base":"223 59 59","--color-danger-gradient":"180 -13 20","--color-danger-button-text":"255 255 255","--color-form-base":"46 117 163"}';
24+
$themeId = $this->connection->fetchOne(
25+
'SELECT id FROM color_theme WHERE slug = ?',
26+
[$name]
27+
);
28+
29+
if ($themeId) {
30+
// a Chamilo style is already there, do nothing
31+
} else {
32+
$this->connection->executeStatement(
33+
'INSERT INTO color_theme (title, variables, slug, created_at, updated_at)
34+
VALUES (?, ?, ?, NOW(), NOW())',
35+
[
36+
"Chamilo",
37+
$json,
38+
$name
39+
]
40+
);
41+
$this->connection->executeStatement(
42+
'INSERT INTO access_url_rel_color_theme (url_id, color_theme_id, active, created_at, updated_at)
43+
VALUES (?, ?, ?, NOW(), NOW())',
44+
[
45+
1,
46+
1,
47+
1
48+
]
49+
);
50+
}
51+
$this->write("Added default Chamilo CSS theme in the color_theme table.");
52+
}
53+
54+
public function down(Schema $schema): void
55+
{
56+
$this->addSql("
57+
DELETE FROM color_theme WHERE slug = 'chamilo'
58+
");
59+
$this->write("Removed default Chamilo CSS theme in the color_theme table.");
60+
}
61+
}

0 commit comments

Comments
 (0)