2121
2222class SyncProfileEventListener
2323{
24- protected $ avatarUploader ;
25- protected $ extensions ;
26- protected $ settings ;
27- protected $ container ;
28- protected $ config ;
24+ private $ avatarUploader ;
25+ private $ extensions ;
26+ private $ settings ;
27+ private $ container ;
28+ private $ config ;
29+ private $ log ;
2930
3031 public function __construct (
3132 Container $ container ,
3233 AvatarUploader $ avatarUploader ,
3334 ExtensionManager $ extensions ,
3435 SettingsRepositoryInterface $ settings ,
3536 Config $ config ,
37+ LoggerInterface $ log ,
3638 ) {
3739 $ this ->avatarUploader = $ avatarUploader ;
3840 $ this ->extensions = $ extensions ;
3941 $ this ->settings = $ settings ;
4042 $ this ->container = $ container ;
4143 $ this ->config = $ config ;
44+ $ this ->log = $ log ;
4245 }
4346
4447 public function subscribe (Dispatcher $ events )
@@ -51,12 +54,12 @@ public function syncEvent(SyncProfileEvent $event)
5154 $ email = $ event ->email ;
5255 $ user = User::query ()->where ("email " , $ email )->first ();
5356 if (!$ user ) {
54- $ this ->debugLog ("Failed sync profile, due to $ email not found " );
57+ $ this ->log -> debug ("Failed sync profile, due to $ email not found " );
5558 return ;
5659 }
5760 $ this ->sync ($ user , $ event ->attributes );
5861 $ user ->save ();
59- $ this ->debugLog ("Synced $ event ->email " );
62+ $ this ->log -> debug ("Synced $ event ->email " );
6063 }
6164
6265 public function sync (User $ user , $ attributes )
@@ -71,7 +74,7 @@ public function sync(User $user, $attributes)
7174 && $ nickname != $ user ->$ nickname
7275 ) {
7376 if (!$ this ->extensions ->isEnabled ('flarum-nicknames ' )) {
74- $ this ->debugLog ("Sync user profile: 'nickname' failed, because extension 'flarum-nicknames' is not enabled. " );
77+ $ this ->log -> debug ("Sync user profile: 'nickname' failed, because extension 'flarum-nicknames' is not enabled. " );
7578 } else {
7679 $ user ->nickname = $ nickname ;
7780 }
@@ -86,7 +89,7 @@ public function sync(User $user, $attributes)
8689 && $ bio != $ user ->bio
8790 ) {
8891 if (!$ this ->extensions ->isEnabled ('fof-user-bio ' )) {
89- $ this ->debugLog ("Sync user profile: 'nickname' failed, because extension 'fof/user-bio' is not enabled. " );
92+ $ this ->log -> debug ("Sync user profile: 'nickname' failed, because extension 'fof/user-bio' is not enabled. " );
9093 } else {
9194 $ user ->bio = $ bio ;
9295 }
@@ -136,7 +139,7 @@ public function sync(User $user, $attributes)
136139 && $ this ->settings ->get ('liplum-sync-profile-core.sync-masquerade ' , false )
137140 ) {
138141 if (!$ this ->extensions ->isEnabled ('fof-masquerade ' )) {
139- $ this ->debugLog ("Profile sync of of-masquerade failed, because extension 'fof/masquerade' is not enabled. " );
142+ $ this ->log -> debug ("Profile sync of of-masquerade failed, because extension 'fof/masquerade' is not enabled. " );
140143 } else {
141144 $ controller = UserConfigureController::class;
142145 if (is_string ($ controller )) {
@@ -164,15 +167,4 @@ public function sync(User $user, $attributes)
164167 }
165168 }
166169 }
167-
168- protected function debugLog (string $ message )
169- {
170- if ($ this ->config ->inDebugMode ()) {
171- /**
172- * @var LoggerInterface
173- */
174- $ logger = resolve (LoggerInterface::class);
175- $ logger ->info ($ message );
176- }
177- }
178170}
0 commit comments