1010use OCA \Passwords \Db \EntityInterface ;
1111use OCA \Passwords \Helper \Settings \UserSettingsHelper ;
1212use OCA \Passwords \Services \ConfigurationService ;
13+ use OCA \Passwords \Services \EnvironmentService ;
1314use OCA \Passwords \Services \Object \AbstractModelService ;
1415use OCA \Passwords \Services \Object \AbstractService ;
1516use OCA \Passwords \Services \Object \FolderService ;
@@ -73,24 +74,24 @@ class DeleteUserDataHelper {
7374 /**
7475 * DeleteUserDataHelper constructor.
7576 *
76- * @param null|string $userId
7777 * @param TagService $tagService
7878 * @param ShareService $shareService
7979 * @param UserSettingsHelper $settings
8080 * @param FolderService $folderService
8181 * @param ConfigurationService $config
82+ * @param EnvironmentService $environment
8283 * @param PasswordService $passwordService
8384 */
8485 public function __construct (
85- ?string $ userId ,
8686 TagService $ tagService ,
8787 ShareService $ shareService ,
8888 UserSettingsHelper $ settings ,
8989 FolderService $ folderService ,
9090 ConfigurationService $ config ,
91+ EnvironmentService $ environment ,
9192 PasswordService $ passwordService
9293 ) {
93- $ this ->userId = $ userId ;
94+ $ this ->userId = $ environment -> getUserId () ;
9495 $ this ->config = $ config ;
9596 $ this ->settings = $ settings ;
9697 $ this ->tagService = $ tagService ;
@@ -125,7 +126,9 @@ protected function deleteObjects(AbstractService $service, string $userId): void
125126 /** @var EntityInterface $objects */
126127 $ objects = $ service ->findByUserId ($ userId );
127128
128- foreach ($ objects as $ tag ) $ service ->delete ($ tag );
129+ foreach ($ objects as $ tag ) {
130+ $ service ->delete ($ tag );
131+ }
129132 }
130133
131134 /**
@@ -134,13 +137,17 @@ protected function deleteObjects(AbstractService $service, string $userId): void
134137 protected function deleteUserSettings (string $ userId ): void {
135138 $ settings = array_keys ($ this ->settings ->list ($ userId ));
136139
137- foreach ($ settings as $ setting ) $ this ->settings ->reset ($ setting , $ userId );
140+ foreach ($ settings as $ setting ) {
141+ $ this ->settings ->reset ($ setting , $ userId );
142+ }
138143 }
139144
140145 /**
141146 * @param string $userId
142147 */
143148 protected function deleteUserConfig (string $ userId ): void {
144- foreach ($ this ->userConfigKeys as $ key ) $ this ->config ->deleteUserValue ($ key , $ userId );
149+ foreach ($ this ->userConfigKeys as $ key ) {
150+ $ this ->config ->deleteUserValue ($ key , $ userId );
151+ }
145152 }
146153}
0 commit comments