-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
47 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Neusta\Pimcore\BackendBrandingBundle\Controller; | ||
|
||
use Symfony\Component\HttpFoundation\Response; | ||
use Symfony\Component\HttpKernel\Attribute\AsController; | ||
use Symfony\Component\Routing\Annotation\Route; | ||
|
||
#[AsController, Route('/neusta/backend-branding/js', name: 'neusta_pimcore_backend_branding_js')] | ||
final class JsController | ||
{ | ||
/** | ||
* @param array<string, array{favIcon: string}> $config | ||
*/ | ||
public function __construct( | ||
private readonly string $env, | ||
private readonly array $config, | ||
) { | ||
} | ||
|
||
public function __invoke(): Response | ||
{ | ||
$js = []; | ||
|
||
if ($favIcon = $this->config[$this->env]['favIcon'] ?? null) { | ||
$js[] = <<<JS | ||
document.querySelector("link[rel*='icon']").href = '{$favIcon}'; | ||
JS; | ||
} | ||
|
||
return new Response(implode("\n", $js), Response::HTTP_OK, ['Content-type' => 'text/javascript']); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters