forked from contao/contao
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add contao.backend.theme config for setting a global theme
- Loading branch information
Showing
10 changed files
with
105 additions
and
42 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
57 changes: 57 additions & 0 deletions
57
core-bundle/src/EventListener/DataContainer/BackendThemesOptionsListener.php
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,57 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of Contao. | ||
* | ||
* (c) Leo Feyer | ||
* | ||
* @license LGPL-3.0-or-later | ||
*/ | ||
|
||
namespace Contao\CoreBundle\EventListener\DataContainer; | ||
|
||
use Contao\Backend; | ||
use Contao\CoreBundle\BackendTheme\BackendThemes; | ||
use Contao\CoreBundle\ServiceAnnotation\Callback; | ||
use Contao\DataContainer; | ||
|
||
class BackendThemesOptionsListener | ||
{ | ||
private BackendThemes $backendThemes; | ||
private array $backendConfig; | ||
|
||
public function __construct(BackendThemes $backendThemes, array $backendConfig) | ||
{ | ||
$this->backendThemes = $backendThemes; | ||
$this->backendConfig = $backendConfig; | ||
} | ||
|
||
/** | ||
* @Callback(table="tl_user", target="fields.backendTheme.options") | ||
*/ | ||
public function options(DataContainer $dc): array | ||
{ | ||
$themes = $this->backendThemes->getThemeNames(); | ||
$themes = array_merge($themes, array_values(Backend::getThemes())); | ||
|
||
return array_combine($themes, $themes); | ||
} | ||
|
||
/** | ||
* @Callback(table="tl_user", target="config.onload") | ||
*/ | ||
public function onload($dc): void | ||
{ | ||
if (!$dc instanceof DataContainer) { | ||
return; | ||
} | ||
|
||
if (null === $this->backendConfig['theme']) { | ||
return; | ||
} | ||
|
||
$GLOBALS['TL_DCA']['tl_user']['fields']['backendTheme']['eval']['disabled'] = true; | ||
} | ||
} |
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
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