1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony). |
4
|
|
|
* |
5
|
|
|
* Copyright (C) 2019 - 2023 Jan Böhmer (https://github.com/jbtronics) |
6
|
|
|
* |
7
|
|
|
* This program is free software: you can redistribute it and/or modify |
8
|
|
|
* it under the terms of the GNU Affero General Public License as published |
9
|
|
|
* by the Free Software Foundation, either version 3 of the License, or |
10
|
|
|
* (at your option) any later version. |
11
|
|
|
* |
12
|
|
|
* This program is distributed in the hope that it will be useful, |
13
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
14
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15
|
|
|
* GNU Affero General Public License for more details. |
16
|
|
|
* |
17
|
|
|
* You should have received a copy of the GNU Affero General Public License |
18
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>. |
19
|
|
|
*/ |
20
|
|
|
|
21
|
|
|
namespace App\Form\Type; |
22
|
|
|
|
23
|
|
|
use App\Entity\UserSystem\User; |
24
|
|
|
use Symfony\Component\Form\AbstractType; |
25
|
|
|
use Symfony\Component\Form\Extension\Core\Type\ChoiceType; |
26
|
|
|
use Symfony\Component\OptionsResolver\OptionsResolver; |
27
|
|
|
|
28
|
|
|
class ThemeChoiceType extends AbstractType |
29
|
|
|
{ |
30
|
|
|
private array $available_themes; |
31
|
|
|
|
32
|
|
|
public function __construct(array $available_themes) |
33
|
|
|
{ |
34
|
|
|
$this->available_themes = $available_themes; |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
public function getParent() |
38
|
|
|
{ |
39
|
|
|
return ChoiceType::class; |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
public function configureOptions(OptionsResolver $resolver) |
43
|
|
|
{ |
44
|
|
|
$resolver->setDefaults([ |
45
|
|
|
'choices' => $this->available_themes, |
46
|
|
|
'choice_label' => static function ($entity, $key, $value) { |
47
|
|
|
return $value; |
48
|
|
|
}, |
49
|
|
|
'attr' => [ |
50
|
|
|
'data-controller' => 'elements--selectpicker', |
51
|
|
|
'title' => 'selectpicker.nothing_selected', |
52
|
|
|
], |
53
|
|
|
'choice_translation_domain' => false, |
54
|
|
|
'placeholder' => 'user_settings.theme.placeholder' |
55
|
|
|
]); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
} |