77use Drupal \Core \Config \ImmutableConfig ;
88use Drupal \Core \DependencyInjection \DependencySerializationTrait ;
99use Drupal \Core \Entity \EntityFieldManagerInterface ;
10+ use Drupal \Core \Extension \InfoParser ;
11+ use Drupal \Core \Extension \ModuleHandlerInterface ;
1012use Drupal \Core \Form \ConfigFormBase ;
1113use Drupal \Core \Form \FormStateInterface ;
1214use Drupal \Core \Language \LanguageManagerInterface ;
@@ -50,6 +52,7 @@ public function __construct(
5052 private readonly LanguageManagerInterface $ languageManager ,
5153 private readonly EntityFieldManagerInterface $ entityFieldManager ,
5254 private readonly RoleStorageInterface $ roleStorage ,
55+ private readonly ModuleHandlerInterface $ moduleHandler ,
5356 private readonly Settings $ settings ,
5457 private readonly PretixHelper $ pretixHelper ,
5558 ) {
@@ -71,6 +74,7 @@ public static function create(ContainerInterface $container): self {
7174 $ container ->get ('language_manager ' ),
7275 $ container ->get ('entity_field.manager ' ),
7376 $ container ->get ('entity_type.manager ' )->getStorage ('user_role ' ),
77+ $ container ->get ('module_handler ' ),
7478 $ settings ,
7579 $ pretixHelper ,
7680 );
@@ -137,6 +141,28 @@ public function buildForm(array $form, FormStateInterface $form_state) {
137141 $ this ->buildFormEventNodes ($ form );
138142 $ this ->buildFormEventForm ($ form );
139143
144+ $ form ['module_info ' ] = [
145+ '#type ' => 'container ' ,
146+ ];
147+
148+ try {
149+ $ project = 'dpl_pretix ' ;
150+ $ module = $ this ->moduleHandler ->getModule ($ project );
151+ $ info = (new InfoParser ())->parse ($ module ->getFileInfo ()
152+ ->getPathname ());
153+
154+ $ info ['project ' ] = $ project ;
155+ $ form ['module_info ' ]['version ' ] = [
156+ '#markup ' => $ this ->t ('@name version: @version ' ,
157+ ['@name ' => $ info ['name ' ], '@version ' => $ info ['version ' ] ?? '👻 ' ],
158+ ['context ' => 'dpl_pretix ' ]
159+ ),
160+ ];
161+ }
162+ catch (\Exception ) {
163+ // Silently ignore any errors.
164+ }
165+
140166 $ form ['admin ' ] = [
141167 '#type ' => 'container ' ,
142168
0 commit comments