Skip to content

Commit 3445eb1

Browse files
committed
Add support for theme configuration
1 parent ef62f56 commit 3445eb1

File tree

3 files changed

+67
-2
lines changed

3 files changed

+67
-2
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
/**
3+
* Configuration of SimpleSAMLphp themevanila.
4+
*/
5+
$config = [
6+
'cookiePolicy' => [
7+
],
8+
'enable_cookies_banner' => False,
9+
'ribbon_text' => 'Demo',
10+
];
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?php
2+
declare(strict_types=1);
3+
4+
namespace SimpleSAML\Module\mymodule;
5+
6+
use SimpleSAML\Configuration;
7+
use SimpleSAML\Session;
8+
use Twig\Environment;
9+
use SimpleSAML\XHTML\TemplateControllerInterface;
10+
11+
class VanillaThemeController implements TemplateControllerInterface
12+
{
13+
/** @var \SimpleSAML\Configuration */
14+
protected Configuration $themeconfig;
15+
16+
/**
17+
* Controller constructor.
18+
*
19+
* It initializes the global configuration and auth source configuration for the controllers implemented here.
20+
*
21+
* @param \SimpleSAML\Configuration $config The configuration to use by the controllers.
22+
* @param \SimpleSAML\Session $session The session to use by the controllers.
23+
*
24+
* @throws \Exception
25+
*/
26+
public function __construct(
27+
protected Configuration $config,
28+
protected Session $session
29+
) {
30+
$this->themeconfig = Configuration::getConfig('module_themevanilla.php');
31+
}
32+
33+
/**
34+
* Modify the twig environment after its initialization (e.g. add filters or extensions).
35+
*
36+
* @param \Twig\Environment $twig The current twig environment.
37+
* @return void
38+
*/
39+
public function setUpTwig(Environment &$twig): void
40+
{
41+
}
42+
43+
/**
44+
* Add, delete or modify the data passed to the template.
45+
*
46+
* This method will be called right before displaying the template.
47+
*
48+
* @param array $data The current data used by the template.
49+
* @return void
50+
*/
51+
public function display(array &$data): void
52+
{
53+
$data['config'] = $this->themeconfig;
54+
}
55+
}

themes/ssp/default/_header.twig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{% block header %}
22
<header id="header">
3-
{% if ribbonnText is defined %}
3+
{% if config.ribbon_text is defined %}
44
<div class="corner-ribbon red">
5-
{{ 'ribbonText'|trans }}
5+
{{ 'config.ribbon_text'|trans }}
66
</div>
77
{% endif %}
88
<div class="text-center ssp-logo">

0 commit comments

Comments
 (0)