Skip to content

Commit

Permalink
Internal: Validate if theme asset exists - refs BT#21621
Browse files Browse the repository at this point in the history
  • Loading branch information
AngelFQC committed Jul 4, 2024
1 parent 6e81d5b commit a329033
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
1 change: 0 additions & 1 deletion src/CoreBundle/ServiceHelper/MailHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ public function send(
'link' => $additionalParameters['link'] ?? '',
'automatic_email_text' => $automaticEmailText,
'content' => $body,
'theme' => $this->themeHelper->getVisualTheme(),
];

if (!empty($recipientEmail)) {
Expand Down
10 changes: 9 additions & 1 deletion src/CoreBundle/ServiceHelper/ThemeHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

use Chamilo\CoreBundle\Settings\SettingsManager;
use Chamilo\CourseBundle\Settings\SettingsCourseManager;
use League\Flysystem\FilesystemException;
use League\Flysystem\FilesystemOperator;
use Symfony\Component\DependencyInjection\Attribute\Autowire;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\Routing\RouterInterface;

Expand All @@ -22,6 +25,7 @@ public function __construct(
private readonly CidReqHelper $cidReqHelper,
private readonly SettingsCourseManager $settingsCourseManager,
private readonly RouterInterface $router,
#[Autowire(service: 'oneup_flysystem.themes_filesystem')] private readonly FilesystemOperator $filesystem,
) {}

/**
Expand Down Expand Up @@ -71,7 +75,11 @@ public function getThemeAssetUrl(string $path, bool $absolute = false): string
{
$themeName = $this->getVisualTheme();

if (empty($themeName)) {
try {
if (!$this->filesystem->fileExists($themeName.DIRECTORY_SEPARATOR.$path)) {
return '';
}
} catch (FilesystemException) {
return '';
}

Expand Down

0 comments on commit a329033

Please sign in to comment.