39
39
*/
40
40
class AppLifecycle extends AbstractAppLifecycle
41
41
{
42
- /**
43
- * @var EntityRepositoryInterface
44
- */
45
- private $ appRepository ;
42
+ private EntityRepositoryInterface $ appRepository ;
46
43
47
- /**
48
- * @var PermissionPersister
49
- */
50
- private $ permissionPersister ;
44
+ private PermissionPersister $ permissionPersister ;
51
45
52
- /**
53
- * @var CustomFieldPersister
54
- */
55
- private $ customFieldPersister ;
46
+ private CustomFieldPersister $ customFieldPersister ;
56
47
57
- /**
58
- * @var AbstractAppLoader
59
- */
60
- private $ appLoader ;
48
+ private AbstractAppLoader $ appLoader ;
61
49
62
- /**
63
- * @var EventDispatcherInterface
64
- */
65
- private $ eventDispatcher ;
50
+ private EventDispatcherInterface $ eventDispatcher ;
66
51
67
- /**
68
- * @var AppRegistrationService
69
- */
70
- private $ registrationService ;
52
+ private AppRegistrationService $ registrationService ;
71
53
72
- /**
73
- * @var AppStateService
74
- */
75
- private $ appStateService ;
54
+ private AppStateService $ appStateService ;
76
55
77
- /**
78
- * @var ActionButtonPersister
79
- */
80
- private $ actionButtonPersister ;
56
+ private ActionButtonPersister $ actionButtonPersister ;
81
57
82
- /**
83
- * @var TemplatePersister
84
- */
85
- private $ templatePersister ;
58
+ private TemplatePersister $ templatePersister ;
86
59
87
- /**
88
- * @var WebhookPersister
89
- */
90
- private $ webhookPersister ;
60
+ private WebhookPersister $ webhookPersister ;
91
61
92
62
/**
93
63
* @internal (flag:FEATURE_NEXT_14357) make persister not nullable on removal
94
- *
95
- * @var PaymentMethodPersister|null
96
64
*/
97
- private $ paymentMethodPersister ;
65
+ private ? PaymentMethodPersister $ paymentMethodPersister ;
98
66
99
- /**
100
- * @var EntityRepositoryInterface
101
- */
102
- private $ languageRepository ;
67
+ private EntityRepositoryInterface $ languageRepository ;
103
68
104
- /*
105
- * @var SystemConfigService
106
- */
107
- private $ systemConfigService ;
69
+ private SystemConfigService $ systemConfigService ;
108
70
109
- /*
110
- * @var ConfigValidator
111
- */
112
- private $ configValidator ;
71
+ private ConfigValidator $ configValidator ;
113
72
114
- /**
115
- * @var string
116
- */
117
- private $ projectDir ;
73
+ private string $ projectDir ;
74
+
75
+ private EntityRepositoryInterface $ integrationRepository ;
118
76
119
77
public function __construct (
120
78
EntityRepositoryInterface $ appRepository ,
@@ -131,6 +89,7 @@ public function __construct(
131
89
EntityRepositoryInterface $ languageRepository ,
132
90
SystemConfigService $ systemConfigService ,
133
91
ConfigValidator $ configValidator ,
92
+ EntityRepositoryInterface $ integrationRepository ,
134
93
string $ projectDir
135
94
) {
136
95
$ this ->appRepository = $ appRepository ;
@@ -148,6 +107,7 @@ public function __construct(
148
107
$ this ->languageRepository = $ languageRepository ;
149
108
$ this ->systemConfigService = $ systemConfigService ;
150
109
$ this ->configValidator = $ configValidator ;
110
+ $ this ->integrationRepository = $ integrationRepository ;
151
111
}
152
112
153
113
public function getDecorated (): AbstractAppLifecycle
@@ -195,10 +155,10 @@ public function delete(string $appName, array $app, Context $context): void
195
155
$ appEntity = $ this ->loadApp ($ app ['id ' ], $ context );
196
156
197
157
if ($ appEntity ->isActive ()) {
198
- $ this ->appStateService ->deactivateApp ($ app [ ' id ' ] , $ context );
158
+ $ this ->appStateService ->deactivateApp ($ appEntity -> getId () , $ context );
199
159
}
200
160
201
- $ this ->removeAppAndRole ($ app [ ' id ' ], $ app [ ' roleId ' ] , $ context );
161
+ $ this ->removeAppAndRole ($ appEntity , $ context );
202
162
}
203
163
204
164
private function updateApp (
@@ -231,7 +191,7 @@ private function updateApp(
231
191
try {
232
192
$ this ->registrationService ->registerApp ($ manifest , $ id , $ secretAccessKey , $ context );
233
193
} catch (AppRegistrationException $ e ) {
234
- $ this ->removeAppAndRole ($ id , $ roleId , $ context );
194
+ $ this ->removeAppAndRole ($ app , $ context );
235
195
236
196
throw $ e ;
237
197
}
@@ -280,17 +240,18 @@ private function updateApp(
280
240
return $ app ;
281
241
}
282
242
283
- private function removeAppAndRole (string $ appId , string $ roleId , Context $ context ): void
243
+ private function removeAppAndRole (AppEntity $ app , Context $ context ): void
284
244
{
285
245
// throw event before deleting app from db as it may be delivered via webhook to the deleted app
286
246
$ this ->eventDispatcher ->dispatch (
287
- new AppDeletedEvent ($ appId , $ context )
247
+ new AppDeletedEvent ($ app -> getId () , $ context )
288
248
);
289
249
290
- $ context ->scope (Context::SYSTEM_SCOPE , function (Context $ context ) use ($ appId ): void {
291
- $ this ->appRepository ->delete ([['id ' => $ appId ]], $ context );
250
+ $ context ->scope (Context::SYSTEM_SCOPE , function (Context $ context ) use ($ app ): void {
251
+ $ this ->appRepository ->delete ([['id ' => $ app ->getId ()]], $ context );
252
+ $ this ->integrationRepository ->delete ([['id ' => $ app ->getIntegrationId ()]], $ context );
292
253
});
293
- $ this ->permissionPersister ->removeRole ($ roleId );
254
+ $ this ->permissionPersister ->removeRole ($ app -> getAclRoleId () );
294
255
}
295
256
296
257
private function updateMetadata (array $ metadata , Context $ context ): void
@@ -309,6 +270,7 @@ private function enrichInstallMetadata(Manifest $manifest, array $metadata, stri
309
270
'writeAccess ' => true ,
310
271
'accessKey ' => AccessKeyHelper::generateAccessKey ('integration ' ),
311
272
'secretAccessKey ' => $ secret ,
273
+ 'admin ' => false ,
312
274
];
313
275
$ metadata ['aclRole ' ] = [
314
276
'id ' => $ roleId ,
0 commit comments