-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy pathSupportMetaModelsController.php
More file actions
139 lines (124 loc) · 4.31 KB
/
SupportMetaModelsController.php
File metadata and controls
139 lines (124 loc) · 4.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
<?php
/**
* This file is part of MetaModels/core.
*
* (c) 2012-2025 The MetaModels team.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* This project is provided in good faith and hope to be usable by anyone.
*
* @package MetaModels/core
* @author Christian Schiffler <c.schiffler@cyberspectrum.de>
* @author Sven Baumann <baumann.sv@gmail.com>
* @author Richard Henkenjohann <richardhenkenjohann@googlemail.com>
* @author Ingolf Steinhardt <info@e-spin.de>
* @copyright 2012-2025 The MetaModels team.
* @license https://github.com/MetaModels/core/blob/master/LICENSE LGPL-3.0-or-later
* @filesource
*/
namespace MetaModels\CoreBundle\Controller\Backend;
use Contao\CoreBundle\Controller\Backend\AbstractBackendController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Contracts\Translation\TranslatorInterface;
use Twig\Environment as TwigEnvironment;
/**
* This controller provides the add-all action in input screens.
*
* @psalm-suppress PropertyNotSetInConstructor
*/
class SupportMetaModelsController extends AbstractBackendController
{
/**
* The twig engine.
*
* @var TwigEnvironment
*/
private TwigEnvironment $twig;
/**
* The translator.
*
* @var TranslatorInterface
*/
private TranslatorInterface $translator;
/**
* The github contributors file.
*
* @var string
*/
private string $github;
/**
* The transifex contributors file.
*
* @var string
*/
private string $transifex;
/**
* Create a new instance.
*
* @param TwigEnvironment $twig The twig engine.
* @param TranslatorInterface $translator The translator.
* @param string $github Path to the github contributor json list.
* @param string $transifex Path to the transifex contributor json list.
*/
public function __construct(TwigEnvironment $twig, TranslatorInterface $translator, $github, $transifex)
{
$this->twig = $twig;
$this->translator = $translator;
$this->github = $github;
$this->transifex = $transifex;
}
/**
* Invoke this.
*
* @return Response The template data.
*
* @SuppressWarnings(PHPMD.Superglobals)
*/
public function __invoke()
{
$headline = $this->translator->trans('menu.label', [], 'metamodels_support');
$GLOBALS['TL_CSS']['metamodels.core'] = '/bundles/metamodelscore/css/supportscreen.css';
return $this->render(
'@MetaModelsCore/misc/support.html.twig',
[
'title' => $headline,
'headline' => $headline,
'sub_headline' =>
$this->translator->trans('main_headline', [], 'metamodels_support'),
'head_contributor' =>
$this->translator->trans('contributor_headline', [], 'metamodels_support'),
'purpose' => $this->translator->trans('purpose', [], 'metamodels_support'),
'other_donations' =>
$this->translator->trans('other_donations', [], 'metamodels_support'),
'main_text' =>
$this->translator->trans('main_text', [], 'metamodels_support'),
'help_headline' =>
$this->translator->trans('help_headline', [], 'metamodels_support'),
'help_text' =>
$this->translator->trans('help_text', [], 'metamodels_support'),
'github_contributors' => $this->getJsonFile($this->github),
'transifex_contributors' => $this->getJsonFile($this->transifex)
]
);
}
/**
* Load the passed file and decode it.
*
* @param string $filename The file name.
*
* @return array
*/
private function getJsonFile($filename)
{
if (!\is_readable($filename)) {
return [];
}
if (false === ($fileContents = \file_get_contents($filename))) {
return [];
}
$contents = \json_decode($fileContents, true);
return $contents ?: [];
}
}