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