1111use OCA \DAV \AppInfo \Application ;
1212use OCA \DAV \Service \ExampleContactService ;
1313use OCA \DAV \Service \ExampleEventService ;
14- use OCP \App \IAppManager ;
1514use OCP \AppFramework \Http \TemplateResponse ;
1615use OCP \AppFramework \Services \IAppConfig ;
1716use OCP \AppFramework \Services \IInitialState ;
@@ -22,49 +21,23 @@ class ExampleContentSettings implements ISettings {
2221 public function __construct (
2322 private readonly IAppConfig $ appConfig ,
2423 private readonly IInitialState $ initialState ,
25- private readonly IAppManager $ appManager ,
2624 private readonly ExampleEventService $ exampleEventService ,
2725 private readonly ExampleContactService $ exampleContactService ,
2826 ) {
2927 }
3028
3129 public function getForm (): TemplateResponse {
32- $ calendarEnabled = $ this ->appManager ->isEnabledForUser ('calendar ' );
33- $ contactsEnabled = $ this ->appManager ->isEnabledForUser ('contacts ' );
34- $ this ->initialState ->provideInitialState ('calendarEnabled ' , $ calendarEnabled );
35- $ this ->initialState ->provideInitialState ('contactsEnabled ' , $ contactsEnabled );
36-
37- if ($ calendarEnabled ) {
38- $ enableDefaultEvent = $ this ->exampleEventService ->shouldCreateExampleEvent ();
39- $ this ->initialState ->provideInitialState ('create_example_event ' , $ enableDefaultEvent );
40- $ this ->initialState ->provideInitialState (
41- 'has_custom_example_event ' ,
42- $ this ->exampleEventService ->hasCustomExampleEvent (),
43- );
44- }
45-
46- if ($ contactsEnabled ) {
47- $ this ->initialState ->provideInitialState (
48- 'enableDefaultContact ' ,
49- $ this ->exampleContactService ->isDefaultContactEnabled (),
50- );
51- $ this ->initialState ->provideInitialState (
52- 'hasCustomDefaultContact ' ,
53- $ this ->appConfig ->getAppValueBool ('hasCustomDefaultContact ' ),
54- );
55- }
30+ $ this ->initialState ->provideInitialState ('create_example_event ' , $ this ->exampleEventService ->shouldCreateExampleEvent ());
31+ $ this ->initialState ->provideInitialState ('has_custom_example_event ' , $ this ->exampleEventService ->hasCustomExampleEvent ());
32+ $ this ->initialState ->provideInitialState ('enableDefaultContact ' , $ this ->exampleContactService ->isDefaultContactEnabled ());
33+ $ this ->initialState ->provideInitialState ('hasCustomDefaultContact ' , $ this ->appConfig ->getAppValueBool ('hasCustomDefaultContact ' ));
5634
5735 Util::addStyle (Application::APP_ID , 'settings-admin-example-content ' );
5836 Util::addScript (Application::APP_ID , 'settings-admin-example-content ' );
5937 return new TemplateResponse (Application::APP_ID , 'settings-admin-example-content ' );
6038 }
6139
6240 public function getSection (): ?string {
63- if (!$ this ->appManager ->isEnabledForUser ('contacts ' )
64- && !$ this ->appManager ->isEnabledForUser ('calendar ' )) {
65- return null ;
66- }
67-
6841 return 'groupware ' ;
6942 }
7043
0 commit comments