Minor: Format code

pull/5654/head
Angel Fernando Quiroz Campos 5 months ago
parent bd5b6fbe83
commit 18e8c0a65b
No known key found for this signature in database
GPG Key ID: B284841AE3E562CD
  1. 1
      src/CoreBundle/Controller/SecurityController.php
  2. 11
      src/CoreBundle/Controller/ThemeController.php
  3. 2
      src/CoreBundle/Entity/AccessUrl.php
  4. 2
      src/CoreBundle/Entity/XApiSharedStatement.php
  5. 2
      src/CoreBundle/Migrations/AbstractMigrationChamilo.php
  6. 12
      src/CoreBundle/Migrations/Schema/V200/PriorityMigrationHelper.php
  7. 2
      src/CoreBundle/Migrations/Schema/V200/Version20.php
  8. 4
      src/CoreBundle/Migrations/Schema/V200/Version20170523110000.php
  9. 2
      src/CoreBundle/Migrations/Schema/V200/Version20170625153000.php
  10. 2
      src/CoreBundle/Migrations/Schema/V200/Version20201205102020.php
  11. 7
      src/CoreBundle/Migrations/Schema/V200/Version20201215072919.php
  12. 2
      src/CoreBundle/Migrations/Schema/V200/Version20231110194300.php
  13. 8
      src/CoreBundle/Migrations/Schema/V200/Version20240425192900.php
  14. 4
      src/CoreBundle/Migrations/Schema/V200/Version20240702222600.php
  15. 8
      src/CoreBundle/Migrations/Schema/V200/Version20240704120500.php
  16. 11
      src/CoreBundle/Migrations/Schema/V200/Version20240704185300.php
  17. 5
      src/CoreBundle/ServiceHelper/ThemeHelper.php
  18. 2
      src/CoreBundle/State/AccessUrlRelColorThemeStateProcessor.php
  19. 5
      src/CoreBundle/State/AccessUrlRelColorThemeStateProvider.php
  20. 6
      src/CoreBundle/State/ColorThemeStateProcessor.php
  21. 2
      tests/CoreBundle/Controller/ThemeControllerTest.php

@ -122,6 +122,7 @@ class SecurityController extends AbstractController
if ($this->authorizationChecker->isGranted('IS_AUTHENTICATED_FULLY')) { if ($this->authorizationChecker->isGranted('IS_AUTHENTICATED_FULLY')) {
$user = $this->userHelper->getCurrent(); $user = $this->userHelper->getCurrent();
$data = $this->serializer->serialize($user, 'jsonld', ['groups' => ['user_json:read']]); $data = $this->serializer->serialize($user, 'jsonld', ['groups' => ['user_json:read']]);
return new JsonResponse(['isAuthenticated' => true, 'user' => json_decode($data)], Response::HTTP_OK); return new JsonResponse(['isAuthenticated' => true, 'user' => json_decode($data)], Response::HTTP_OK);
} }

@ -15,6 +15,8 @@ use Symfony\Component\HttpFoundation\ResponseHeaderBag;
use Symfony\Component\HttpFoundation\StreamedResponse; use Symfony\Component\HttpFoundation\StreamedResponse;
use Symfony\Component\Routing\Attribute\Route; use Symfony\Component\Routing\Attribute\Route;
use const DIRECTORY_SEPARATOR;
#[Route('/themes')] #[Route('/themes')]
class ThemeController extends AbstractController class ThemeController extends AbstractController
{ {
@ -25,21 +27,22 @@ class ThemeController extends AbstractController
public function index( public function index(
string $name, string $name,
string $path, string $path,
#[Autowire(service: 'oneup_flysystem.themes_filesystem')] FilesystemOperator $filesystem #[Autowire(service: 'oneup_flysystem.themes_filesystem')]
FilesystemOperator $filesystem
): Response { ): Response {
$themeDir = basename($name); $themeDir = basename($name);
if (!$filesystem->directoryExists($themeDir)) { if (!$filesystem->directoryExists($themeDir)) {
throw $this->createNotFoundException("The folder name does not exist."); throw $this->createNotFoundException('The folder name does not exist.');
} }
$filePath = $themeDir.DIRECTORY_SEPARATOR.$path; $filePath = $themeDir.DIRECTORY_SEPARATOR.$path;
if (!$filesystem->fileExists($filePath)) { if (!$filesystem->fileExists($filePath)) {
throw $this->createNotFoundException("The requested file does not exist."); throw $this->createNotFoundException('The requested file does not exist.');
} }
$response = new StreamedResponse(function () use ($filesystem, $filePath) { $response = new StreamedResponse(function () use ($filesystem, $filePath): void {
$outputStream = fopen('php://output', 'wb'); $outputStream = fopen('php://output', 'wb');
$fileStream = $filesystem->readStream($filePath); $fileStream = $filesystem->readStream($filePath);

@ -545,6 +545,6 @@ class AccessUrl extends AbstractResource implements ResourceInterface, Stringabl
Criteria::expr()->eq('colorTheme', $theme) Criteria::expr()->eq('colorTheme', $theme)
); );
return $this->colorThemes->matching($criteria)->first() ?: null; return $this->colorThemes->matching($criteria)->first() ?: null;
} }
} }

@ -28,7 +28,7 @@ class XApiSharedStatement
#[ORM\Column] #[ORM\Column]
private ?bool $sent = null; private ?bool $sent = null;
public function __construct(array $statement, string $uuid = null, bool $sent = false) public function __construct(array $statement, ?string $uuid = null, bool $sent = false)
{ {
$this->statement = $statement; $this->statement = $statement;
$this->uuid = Uuid::fromString($uuid); $this->uuid = Uuid::fromString($uuid);

@ -40,7 +40,7 @@ abstract class AbstractMigrationChamilo extends AbstractMigration
private LoggerInterface $logger; private LoggerInterface $logger;
/** /**
* Constructor * Constructor.
*/ */
public function __construct(Connection $connection, LoggerInterface $logger) public function __construct(Connection $connection, LoggerInterface $logger)
{ {

@ -6,8 +6,8 @@ declare(strict_types=1);
namespace Chamilo\CoreBundle\Migrations\Schema\V200; namespace Chamilo\CoreBundle\Migrations\Schema\V200;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Connection; use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Schema\Schema;
use Psr\Log\LoggerInterface; use Psr\Log\LoggerInterface;
/** /**
@ -22,7 +22,7 @@ class PriorityMigrationHelper
private LoggerInterface $logger; private LoggerInterface $logger;
/** /**
* Constructor * Constructor.
*/ */
public function __construct(Connection $connection, LoggerInterface $logger) public function __construct(Connection $connection, LoggerInterface $logger)
{ {
@ -56,12 +56,12 @@ class PriorityMigrationHelper
'c_lp', 'c_lp',
'c_lp_item', 'c_lp_item',
'c_student_publication', 'c_student_publication',
'c_attendance_calendar' 'c_attendance_calendar',
]; ];
foreach ($tables as $tableName) { foreach ($tables as $tableName) {
$columns = $schemaManager->listTableColumns($tableName); $columns = $schemaManager->listTableColumns($tableName);
if (!array_key_exists('duration', $columns)) { if (!\array_key_exists('duration', $columns)) {
$this->connection->executeQuery("ALTER TABLE $tableName ADD duration INT DEFAULT NULL"); $this->connection->executeQuery("ALTER TABLE $tableName ADD duration INT DEFAULT NULL");
} }
} }
@ -79,12 +79,12 @@ class PriorityMigrationHelper
'c_lp', 'c_lp',
'c_lp_item', 'c_lp_item',
'c_student_publication', 'c_student_publication',
'c_attendance_calendar' 'c_attendance_calendar',
]; ];
foreach ($tables as $tableName) { foreach ($tables as $tableName) {
$columns = $schemaManager->listTableColumns($tableName); $columns = $schemaManager->listTableColumns($tableName);
if (array_key_exists('duration', $columns)) { if (\array_key_exists('duration', $columns)) {
$this->connection->executeQuery("ALTER TABLE $tableName DROP COLUMN duration"); $this->connection->executeQuery("ALTER TABLE $tableName DROP COLUMN duration");
} }
} }

@ -8,8 +8,8 @@ namespace Chamilo\CoreBundle\Migrations\Schema\V200;
use Chamilo\CoreBundle\DataFixtures\LanguageFixtures; use Chamilo\CoreBundle\DataFixtures\LanguageFixtures;
use Chamilo\CoreBundle\Migrations\AbstractMigrationChamilo; use Chamilo\CoreBundle\Migrations\AbstractMigrationChamilo;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Connection; use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Schema\Schema;
use Psr\Log\LoggerInterface; use Psr\Log\LoggerInterface;
/** /**

@ -20,7 +20,7 @@ final class Version20170523110000 extends AbstractMigrationChamilo
{ {
$this->addSql("CREATE TABLE color_theme (id INT AUTO_INCREMENT NOT NULL, title VARCHAR(255) NOT NULL, variables LONGTEXT NOT NULL COMMENT '(DC2Type:json)', slug VARCHAR(255) NOT NULL, created_at DATETIME NOT NULL COMMENT '(DC2Type:datetime)', updated_at DATETIME NOT NULL COMMENT '(DC2Type:datetime)', PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB ROW_FORMAT = DYNAMIC"); $this->addSql("CREATE TABLE color_theme (id INT AUTO_INCREMENT NOT NULL, title VARCHAR(255) NOT NULL, variables LONGTEXT NOT NULL COMMENT '(DC2Type:json)', slug VARCHAR(255) NOT NULL, created_at DATETIME NOT NULL COMMENT '(DC2Type:datetime)', updated_at DATETIME NOT NULL COMMENT '(DC2Type:datetime)', PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB ROW_FORMAT = DYNAMIC");
$this->addSql("CREATE TABLE access_url_rel_color_theme (id INT AUTO_INCREMENT NOT NULL, url_id INT NOT NULL, color_theme_id INT NOT NULL, active TINYINT(1) NOT NULL, created_at DATETIME NOT NULL COMMENT '(DC2Type:datetime)', updated_at DATETIME NOT NULL COMMENT '(DC2Type:datetime)', INDEX IDX_D2A2E1C981CFDAE7 (url_id), INDEX IDX_D2A2E1C98587EFC5 (color_theme_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB ROW_FORMAT = DYNAMIC"); $this->addSql("CREATE TABLE access_url_rel_color_theme (id INT AUTO_INCREMENT NOT NULL, url_id INT NOT NULL, color_theme_id INT NOT NULL, active TINYINT(1) NOT NULL, created_at DATETIME NOT NULL COMMENT '(DC2Type:datetime)', updated_at DATETIME NOT NULL COMMENT '(DC2Type:datetime)', INDEX IDX_D2A2E1C981CFDAE7 (url_id), INDEX IDX_D2A2E1C98587EFC5 (color_theme_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB ROW_FORMAT = DYNAMIC");
$this->addSql("ALTER TABLE access_url_rel_color_theme ADD CONSTRAINT FK_D2A2E1C981CFDAE7 FOREIGN KEY (url_id) REFERENCES access_url (id)"); $this->addSql('ALTER TABLE access_url_rel_color_theme ADD CONSTRAINT FK_D2A2E1C981CFDAE7 FOREIGN KEY (url_id) REFERENCES access_url (id)');
$this->addSql("ALTER TABLE access_url_rel_color_theme ADD CONSTRAINT FK_D2A2E1C98587EFC5 FOREIGN KEY (color_theme_id) REFERENCES color_theme (id)"); $this->addSql('ALTER TABLE access_url_rel_color_theme ADD CONSTRAINT FK_D2A2E1C98587EFC5 FOREIGN KEY (color_theme_id) REFERENCES color_theme (id)');
} }
} }

@ -107,7 +107,7 @@ class Version20170625153000 extends AbstractMigrationChamilo
} }
$this->addSql('UPDATE c_forum_thread SET thread_date = NOW() WHERE thread_date is NULL OR thread_date = 0'); $this->addSql('UPDATE c_forum_thread SET thread_date = NOW() WHERE thread_date is NULL OR thread_date = 0');
$this->addSql('UPDATE c_forum_thread SET forum_id = NULL WHERE forum_id IS NOT NULL AND forum_id NOT IN (SELECT iid FROM c_forum_forum) '); $this->addSql('UPDATE c_forum_thread SET forum_id = NULL WHERE forum_id IS NOT NULL AND forum_id NOT IN (SELECT iid FROM c_forum_forum) ');
$this->addSql('ALTER TABLE c_forum_thread CHANGE thread_date thread_date DATETIME NOT NULL'); $this->addSql('ALTER TABLE c_forum_thread CHANGE thread_date thread_date DATETIME NOT NULL');
if (false === $table->hasColumn('resource_node_id')) { if (false === $table->hasColumn('resource_node_id')) {

@ -106,7 +106,7 @@ final class Version20201205102020 extends AbstractMigrationChamilo
} }
if (!$table->hasForeignKey('FK_79D3D95A613FECDF')) { if (!$table->hasForeignKey('FK_79D3D95A613FECDF')) {
$this->addSql('UPDATE skill_rel_user SET session_id = NULL WHERE session_id NOT IN (SELECT id FROM session)'); $this->addSql('UPDATE skill_rel_user SET session_id = NULL WHERE session_id NOT IN (SELECT id FROM session)');
$this->addSql( $this->addSql(
'ALTER TABLE skill_rel_user ADD CONSTRAINT FK_79D3D95A613FECDF FOREIGN KEY (session_id) REFERENCES session (id) ON DELETE SET NULL' 'ALTER TABLE skill_rel_user ADD CONSTRAINT FK_79D3D95A613FECDF FOREIGN KEY (session_id) REFERENCES session (id) ON DELETE SET NULL'
); );

@ -16,16 +16,13 @@ class Version20201215072919 extends AbstractMigrationChamilo
return 'Create agenda_reminder table as fallback to allow to use CCalendarEvent entities'; return 'Create agenda_reminder table as fallback to allow to use CCalendarEvent entities';
} }
/**
* @inheritDoc
*/
public function up(Schema $schema): void public function up(Schema $schema): void
{ {
if (!$schema->hasTable('agenda_reminder')) { if (!$schema->hasTable('agenda_reminder')) {
$this->addSql( $this->addSql(
"CREATE TABLE agenda_reminder (id INT AUTO_INCREMENT NOT NULL, event_id INT NOT NULL, date_interval VARCHAR(255) NOT NULL COMMENT '(DC2Type:dateinterval)', sent TINYINT(1) NOT NULL, created_at DATETIME NOT NULL COMMENT '(DC2Type:datetime)', updated_at DATETIME NOT NULL COMMENT '(DC2Type:datetime)', INDEX IDX_416FFA2471F7E88B (event_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB ROW_FORMAT = DYNAMIC" "CREATE TABLE agenda_reminder (id INT AUTO_INCREMENT NOT NULL, event_id INT NOT NULL, date_interval VARCHAR(255) NOT NULL COMMENT '(DC2Type:dateinterval)', sent TINYINT(1) NOT NULL, created_at DATETIME NOT NULL COMMENT '(DC2Type:datetime)', updated_at DATETIME NOT NULL COMMENT '(DC2Type:datetime)', INDEX IDX_416FFA2471F7E88B (event_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB ROW_FORMAT = DYNAMIC"
); );
$this->addSql("ALTER TABLE agenda_reminder ADD CONSTRAINT FK_416FFA2471F7E88B FOREIGN KEY (event_id) REFERENCES c_calendar_event (iid)"); $this->addSql('ALTER TABLE agenda_reminder ADD CONSTRAINT FK_416FFA2471F7E88B FOREIGN KEY (event_id) REFERENCES c_calendar_event (iid)');
} }
} }
} }

@ -10,6 +10,8 @@ use Chamilo\CoreBundle\Migrations\AbstractMigrationChamilo;
use Doctrine\DBAL\Schema\Schema; use Doctrine\DBAL\Schema\Schema;
use Symfony\Component\Finder\Finder; use Symfony\Component\Finder\Finder;
use const DIRECTORY_SEPARATOR;
final class Version20231110194300 extends AbstractMigrationChamilo final class Version20231110194300 extends AbstractMigrationChamilo
{ {
public function getDescription(): string public function getDescription(): string

@ -22,19 +22,19 @@ class Version20240425192900 extends AbstractMigration
$tblAgendaReminder = $schema->getTable('agenda_reminder'); $tblAgendaReminder = $schema->getTable('agenda_reminder');
if ($tblAgendaReminder->hasColumn('type')) { if ($tblAgendaReminder->hasColumn('type')) {
$this->addSql("ALTER TABLE agenda_reminder DROP type"); $this->addSql('ALTER TABLE agenda_reminder DROP type');
} }
$this->addSql("ALTER TABLE agenda_reminder CHANGE id id INT AUTO_INCREMENT NOT NULL"); $this->addSql('ALTER TABLE agenda_reminder CHANGE id id INT AUTO_INCREMENT NOT NULL');
if (!$tblAgendaReminder->hasForeignKey('FK_416FFA2471F7E88B')) { if (!$tblAgendaReminder->hasForeignKey('FK_416FFA2471F7E88B')) {
$this->addSql('DELETE FROM agenda_reminder WHERE event_id IS NULL OR event_id NOT IN (SELECT iid FROM c_calendar_event)'); $this->addSql('DELETE FROM agenda_reminder WHERE event_id IS NULL OR event_id NOT IN (SELECT iid FROM c_calendar_event)');
$this->addSql("ALTER TABLE agenda_reminder ADD CONSTRAINT FK_416FFA2471F7E88B FOREIGN KEY (event_id) REFERENCES c_calendar_event (iid)"); $this->addSql('ALTER TABLE agenda_reminder ADD CONSTRAINT FK_416FFA2471F7E88B FOREIGN KEY (event_id) REFERENCES c_calendar_event (iid)');
} }
if (!$tblAgendaReminder->hasIndex('IDX_416FFA2471F7E88B')) { if (!$tblAgendaReminder->hasIndex('IDX_416FFA2471F7E88B')) {
$this->addSql("CREATE INDEX IDX_416FFA2471F7E88B ON agenda_reminder (event_id)"); $this->addSql('CREATE INDEX IDX_416FFA2471F7E88B ON agenda_reminder (event_id)');
} }
} }
} }

@ -24,13 +24,13 @@ final class Version20240702222600 extends AbstractMigrationChamilo
if (!$tblResourceFile->hasColumn('resource_node_id')) { if (!$tblResourceFile->hasColumn('resource_node_id')) {
$this->addSql('ALTER TABLE resource_file ADD resource_node_id INT DEFAULT NULL'); $this->addSql('ALTER TABLE resource_file ADD resource_node_id INT DEFAULT NULL');
$result = $this->connection->executeQuery("SELECT id, resource_file_id FROM resource_node"); $result = $this->connection->executeQuery('SELECT id, resource_file_id FROM resource_node');
$resourceNodeRows = $result->fetchAllAssociative(); $resourceNodeRows = $result->fetchAllAssociative();
foreach ($resourceNodeRows as $resourceNodeRow) { foreach ($resourceNodeRows as $resourceNodeRow) {
$this->addSql( $this->addSql(
sprintf( sprintf(
"UPDATE resource_file SET resource_node_id = %d WHERE id = %d", 'UPDATE resource_file SET resource_node_id = %d WHERE id = %d',
$resourceNodeRow['id'], $resourceNodeRow['id'],
$resourceNodeRow['resource_file_id'] $resourceNodeRow['resource_file_id']
) )

@ -51,7 +51,7 @@ final class Version20240704120500 extends AbstractMigrationChamilo
$durationInSeconds = $workTime * 60; $durationInSeconds = $workTime * 60;
$this->addSql("UPDATE c_student_publication SET duration = ? WHERE iid = ?", [$durationInSeconds, $id]); $this->addSql('UPDATE c_student_publication SET duration = ? WHERE iid = ?', [$durationInSeconds, $id]);
} }
} }
} }
@ -75,15 +75,15 @@ final class Version20240704120500 extends AbstractMigrationChamilo
$newDuration = null; $newDuration = null;
if (preg_match('/(\d+)([h:](\d+)?)?/', $duration, $matches)) { if (preg_match('/(\d+)([h:](\d+)?)?/', $duration, $matches)) {
$hours = (int)$matches[1]; $hours = (int) $matches[1];
$minutes = 0; $minutes = 0;
if (!empty($matches[3])) { if (!empty($matches[3])) {
$minutes = (int)$matches[3]; $minutes = (int) $matches[3];
} }
$newDuration = ($hours * 3600) + ($minutes * 60); $newDuration = ($hours * 3600) + ($minutes * 60);
} }
if ($newDuration !== null) { if (null !== $newDuration) {
$this->addSql('UPDATE c_attendance_calendar SET duration = ? WHERE iid = ?', [$newDuration, $id]); $this->addSql('UPDATE c_attendance_calendar SET duration = ? WHERE iid = ?', [$newDuration, $id]);
} }
} }

@ -1,5 +1,7 @@
<?php <?php
declare(strict_types=1);
namespace Chamilo\CoreBundle\Migrations\Schema\V200; namespace Chamilo\CoreBundle\Migrations\Schema\V200;
use Chamilo\CoreBundle\Migrations\AbstractMigrationChamilo; use Chamilo\CoreBundle\Migrations\AbstractMigrationChamilo;
@ -7,16 +9,15 @@ use Doctrine\DBAL\Schema\Schema;
use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Finder\Finder; use Symfony\Component\Finder\Finder;
use const DIRECTORY_SEPARATOR;
class Version20240704185300 extends AbstractMigrationChamilo class Version20240704185300 extends AbstractMigrationChamilo
{ {
public function getDescription(): string public function getDescription(): string
{ {
return "Fix stylesheet and theme settings and move theme directory during development"; return 'Fix stylesheet and theme settings and move theme directory during development';
} }
/**
* @inheritDoc
*/
public function up(Schema $schema): void public function up(Schema $schema): void
{ {
$this->addSql("DELETE FROM settings WHERE variable IN ('stylesheets', 'theme')"); $this->addSql("DELETE FROM settings WHERE variable IN ('stylesheets', 'theme')");
@ -40,7 +41,7 @@ class Version20240704185300 extends AbstractMigrationChamilo
if ($entry->isDir()) { if ($entry->isDir()) {
$this->write( $this->write(
sprintf( sprintf(
"Moving theme directory: %s to %s", 'Moving theme directory: %s to %s',
$entry->getRealPath(), $entry->getRealPath(),
$themesDirectory.DIRECTORY_SEPARATOR $themesDirectory.DIRECTORY_SEPARATOR
) )

@ -16,6 +16,8 @@ use Symfony\Component\DependencyInjection\Attribute\Autowire;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface; use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\Routing\RouterInterface; use Symfony\Component\Routing\RouterInterface;
use const DIRECTORY_SEPARATOR;
final class ThemeHelper final class ThemeHelper
{ {
public const DEFAULT_THEME = 'chamilo'; public const DEFAULT_THEME = 'chamilo';
@ -27,7 +29,8 @@ final class ThemeHelper
private readonly CidReqHelper $cidReqHelper, private readonly CidReqHelper $cidReqHelper,
private readonly SettingsCourseManager $settingsCourseManager, private readonly SettingsCourseManager $settingsCourseManager,
private readonly RouterInterface $router, private readonly RouterInterface $router,
#[Autowire(service: 'oneup_flysystem.themes_filesystem')] private readonly FilesystemOperator $filesystem, #[Autowire(service: 'oneup_flysystem.themes_filesystem')]
private readonly FilesystemOperator $filesystem,
) {} ) {}
/** /**

@ -21,7 +21,7 @@ final class AccessUrlRelColorThemeStateProcessor implements ProcessorInterface
public function process($data, Operation $operation, array $uriVariables = [], array $context = []): AccessUrlRelColorTheme public function process($data, Operation $operation, array $uriVariables = [], array $context = []): AccessUrlRelColorTheme
{ {
assert($data instanceof AccessUrlRelColorTheme); \assert($data instanceof AccessUrlRelColorTheme);
$accessUrl = $this->accessUrlHelper->getCurrent(); $accessUrl = $this->accessUrlHelper->getCurrent();
$accessUrl->getActiveColorTheme()?->setActive(false); $accessUrl->getActiveColorTheme()?->setActive(false);

@ -1,5 +1,7 @@
<?php <?php
declare(strict_types=1);
namespace Chamilo\CoreBundle\State; namespace Chamilo\CoreBundle\State;
use ApiPlatform\Metadata\Operation; use ApiPlatform\Metadata\Operation;
@ -16,9 +18,6 @@ class AccessUrlRelColorThemeStateProvider implements ProviderInterface
private readonly AccessUrlHelper $accessUrlHelper, private readonly AccessUrlHelper $accessUrlHelper,
) {} ) {}
/**
* @inheritdoc
*/
public function provide(Operation $operation, array $uriVariables = [], array $context = []) public function provide(Operation $operation, array $uriVariables = [], array $context = [])
{ {
$colorThemes = $this->accessUrlHelper->getCurrent()->getColorThemes(); $colorThemes = $this->accessUrlHelper->getCurrent()->getColorThemes();

@ -16,6 +16,7 @@ use League\Flysystem\FilesystemException;
use League\Flysystem\FilesystemOperator; use League\Flysystem\FilesystemOperator;
use Symfony\Component\DependencyInjection\Attribute\Autowire; use Symfony\Component\DependencyInjection\Attribute\Autowire;
use const DIRECTORY_SEPARATOR;
use const PHP_EOL; use const PHP_EOL;
final class ColorThemeStateProcessor implements ProcessorInterface final class ColorThemeStateProcessor implements ProcessorInterface
@ -24,10 +25,13 @@ final class ColorThemeStateProcessor implements ProcessorInterface
private readonly ProcessorInterface $persistProcessor, private readonly ProcessorInterface $persistProcessor,
private readonly AccessUrlHelper $accessUrlHelper, private readonly AccessUrlHelper $accessUrlHelper,
private readonly EntityManagerInterface $entityManager, private readonly EntityManagerInterface $entityManager,
#[Autowire(service: 'oneup_flysystem.themes_filesystem')] private readonly FilesystemOperator $filesystem, #[Autowire(service: 'oneup_flysystem.themes_filesystem')]
private readonly FilesystemOperator $filesystem,
) {} ) {}
/** /**
* @param mixed $data
*
* @throws FilesystemException * @throws FilesystemException
*/ */
public function process($data, Operation $operation, array $uriVariables = [], array $context = []) public function process($data, Operation $operation, array $uriVariables = [], array $context = [])

@ -11,7 +11,6 @@ use Symfony\Component\HttpFoundation\Response;
class ThemeControllerTest extends WebTestCase class ThemeControllerTest extends WebTestCase
{ {
public function testValidAccess(): void public function testValidAccess(): void
{ {
$client = static::createClient(); $client = static::createClient();
@ -37,7 +36,6 @@ class ThemeControllerTest extends WebTestCase
$this->assertResponseStatusCodeSame(Response::HTTP_INTERNAL_SERVER_ERROR); $this->assertResponseStatusCodeSame(Response::HTTP_INTERNAL_SERVER_ERROR);
$client->request('GET', 'themes/chamilo/../../../.env'); $client->request('GET', 'themes/chamilo/../../../.env');
$this->assertResponseStatusCodeSame(Response::HTTP_INTERNAL_SERVER_ERROR); $this->assertResponseStatusCodeSame(Response::HTTP_INTERNAL_SERVER_ERROR);

Loading…
Cancel
Save