| @@ -90,7 +90,7 @@ | ||
| 90 | 90 |      { | 
| 91 | 91 |          $this->joinElementTable('enupalsocializer_tokens'); | 
| 92 | 92 | |
| 93 | -        if (is_null($this->query)){ | |
| 93 | +        if (is_null($this->query)) { | |
| 94 | 94 | return false; | 
| 95 | 95 | } | 
| 96 | 96 | |
| @@ -103,7 +103,7 @@ | ||
| 103 | 103 |      { | 
| 104 | 104 |          $this->joinElementTable('enupalsocializer_providers'); | 
| 105 | 105 | |
| 106 | -        if (is_null($this->query)){ | |
| 106 | +        if (is_null($this->query)) { | |
| 107 | 107 | return false; | 
| 108 | 108 | } | 
| 109 | 109 | |
| @@ -77,7 +77,7 @@ discard block | ||
| 77 | 77 | */ | 
| 78 | 78 | public static function displayName(): string | 
| 79 | 79 |      { | 
| 80 | -        return Craft::t('enupal-socializer','Socializer'); | |
| 80 | +        return Craft::t('enupal-socializer', 'Socializer'); | |
| 81 | 81 | } | 
| 82 | 82 | |
| 83 | 83 | /** | 
| @@ -172,7 +172,7 @@ discard block | ||
| 172 | 172 | $record = TokenRecord::findOne($this->id); | 
| 173 | 173 | |
| 174 | 174 |              if (!$record) { | 
| 175 | -                throw new \Exception('Invalid Token ID: ' . $this->id); | |
| 175 | +                throw new \Exception('Invalid Token ID: '.$this->id); | |
| 176 | 176 | } | 
| 177 | 177 |          } else { | 
| 178 | 178 | $record->id = $this->id; | 
| @@ -163,8 +163,8 @@ | ||
| 163 | 163 | $fieldClass = get_class($field); | 
| 164 | 164 | |
| 165 | 165 | $supportedClasses = [ | 
| 166 | - PlainText::class => 1, | |
| 167 | - Dropdown::class => 1 | |
| 166 | + PlainText::class => 1, | |
| 167 | + Dropdown::class => 1 | |
| 168 | 168 | ]; | 
| 169 | 169 | |
| 170 | 170 |          if (isset($supportedClasses[$fieldClass])){ | 
| @@ -154,7 +154,7 @@ discard block | ||
| 154 | 154 | public function loginUrl($handle, $options = []) | 
| 155 | 155 |      { | 
| 156 | 156 | $provider = $this->getProviderByHandle($handle); | 
| 157 | -        if (is_null($provider)){ | |
| 157 | +        if (is_null($provider)) { | |
| 158 | 158 |              throw new NotSupportedException('Provider not found or disabled: '.$handle); | 
| 159 | 159 | } | 
| 160 | 160 | |
| @@ -223,12 +223,12 @@ discard block | ||
| 223 | 223 | ]]; | 
| 224 | 224 | |
| 225 | 225 |          foreach ($fields as $field) { | 
| 226 | -            if (!$this->validateFieldClass($field)){ | |
| 226 | +            if (!$this->validateFieldClass($field)) { | |
| 227 | 227 | continue; | 
| 228 | 228 | } | 
| 229 | 229 | |
| 230 | 230 | $option = [ | 
| 231 | -                'label' => $field->name. ' ('.$field->handle.')', | |
| 231 | +                'label' => $field->name.' ('.$field->handle.')', | |
| 232 | 232 | 'value' => $field->handle | 
| 233 | 233 | ]; | 
| 234 | 234 | |
| @@ -251,7 +251,7 @@ discard block | ||
| 251 | 251 | Dropdown::class => 1 | 
| 252 | 252 | ]; | 
| 253 | 253 | |
| 254 | -        if (isset($supportedClasses[$fieldClass])){ | |
| 254 | +        if (isset($supportedClasses[$fieldClass])) { | |
| 255 | 255 | return true; | 
| 256 | 256 | } | 
| 257 | 257 | |
| @@ -465,7 +465,7 @@ discard block | ||
| 465 | 465 |      { | 
| 466 | 466 | $providers = $this->getAllProviderTypes(); | 
| 467 | 467 | |
| 468 | -        if ($excludeCreated){ | |
| 468 | +        if ($excludeCreated) { | |
| 469 | 469 | $providers = $this->getExcludeCreatedProviders(); | 
| 470 | 470 | } | 
| 471 | 471 | |
| @@ -657,7 +657,7 @@ discard block | ||
| 657 | 657 | $adapter = $provider->getAdapter(); | 
| 658 | 658 |          try { | 
| 659 | 659 | $adapter->authenticate(); | 
| 660 | -        } catch (\Exception $e){ | |
| 660 | +        } catch (\Exception $e) { | |
| 661 | 661 |              Craft::error("Unable to Authorize user", __METHOD__); | 
| 662 | 662 | return false; | 
| 663 | 663 | } | 
| @@ -665,11 +665,11 @@ discard block | ||
| 665 | 665 | $userProfile = $adapter->getUserProfile(); | 
| 666 | 666 | $user = Craft::$app->getUser()->getIdentity(); | 
| 667 | 667 | |
| 668 | -        if (!$user){ | |
| 668 | +        if (!$user) { | |
| 669 | 669 | $user = $this->retrieveUser($userProfile, $provider); | 
| 670 | 670 | } | 
| 671 | 671 | |
| 672 | -        if (!$user){ | |
| 672 | +        if (!$user) { | |
| 673 | 673 |              Craft::error("Not user to login", __METHOD__); | 
| 674 | 674 | return false; | 
| 675 | 675 | } | 
| @@ -678,7 +678,7 @@ discard block | ||
| 678 | 678 | |
| 679 | 679 | $user = $this->triggerBeforeLoginUser($user, $provider, $userProfile); | 
| 680 | 680 | |
| 681 | -        if (is_null($user)){ | |
| 681 | +        if (is_null($user)) { | |
| 682 | 682 |              Craft::error("User not valid to login on BeforeLoginEvent", __METHOD__); | 
| 683 | 683 | return false; | 
| 684 | 684 | } | 
| @@ -734,7 +734,7 @@ discard block | ||
| 734 | 734 | */ | 
| 735 | 735 | private function retrieveUser(Profile $userProfile, Provider $provider): ?User | 
| 736 | 736 |      { | 
| 737 | -        if (is_null($userProfile->email)){ | |
| 737 | +        if (is_null($userProfile->email)) { | |
| 738 | 738 |              throw new \Exception("Email address is not provided, please check the settings of your application"); | 
| 739 | 739 | } | 
| 740 | 740 | |
| @@ -745,7 +745,7 @@ discard block | ||
| 745 | 745 | } | 
| 746 | 746 | $settings = Socializer::$app->settings->getSettings(); | 
| 747 | 747 | |
| 748 | -        if (!$settings->enableUserSignUp){ | |
| 748 | +        if (!$settings->enableUserSignUp) { | |
| 749 | 749 | return null; | 
| 750 | 750 | } | 
| 751 | 751 | |
| @@ -773,16 +773,16 @@ discard block | ||
| 773 | 773 | return null; | 
| 774 | 774 | } | 
| 775 | 775 | |
| 776 | -        if (!Craft::$app->elements->saveElement($user)){ | |
| 776 | +        if (!Craft::$app->elements->saveElement($user)) { | |
| 777 | 777 |              Craft::error("Unable to create user: ".json_encode($user->getErrors())); | 
| 778 | 778 |              throw new \Exception("Something went wrong while creating the user"); | 
| 779 | 779 | } | 
| 780 | 780 | |
| 781 | 781 | Craft::$app->users->activateUser($user); | 
| 782 | 782 | |
| 783 | -        if ($settings->userGroupId){ | |
| 783 | +        if ($settings->userGroupId) { | |
| 784 | 784 | $userGroup = Craft::$app->getUserGroups()->getGroupById($settings->userGroupId); | 
| 785 | -            if ($userGroup){ | |
| 785 | +            if ($userGroup) { | |
| 786 | 786 | Craft::$app->getUsers()->assignUserToGroups($user->id, [$userGroup->id]); | 
| 787 | 787 | } | 
| 788 | 788 | } | 
| @@ -824,10 +824,10 @@ discard block | ||
| 824 | 824 | } | 
| 825 | 825 | |
| 826 | 826 |          foreach ($fieldMapping as $item) { | 
| 827 | -            if(isset($item['targetUserField']) && $item['targetUserField']){ | |
| 827 | +            if (isset($item['targetUserField']) && $item['targetUserField']) { | |
| 828 | 828 |                  $profileValue = $profile->{$item['sourceFormField']}; | 
| 829 | 829 | $field = $user->getFieldLayout()->getFieldByHandle($item['targetUserField']); | 
| 830 | -                if ($field){ | |
| 830 | +                if ($field) { | |
| 831 | 831 | $user->setFieldValue($item['targetUserField'], $profileValue); | 
| 832 | 832 | } | 
| 833 | 833 | } | 
| @@ -850,7 +850,7 @@ discard block | ||
| 850 | 850 | $providerRecord = ProviderRecord::findOne($provider->id); | 
| 851 | 851 | |
| 852 | 852 |              if (!$providerRecord) { | 
| 853 | -                throw new Exception(Craft::t("enupal-socializer",'No Provider exists with the ID “{id}”', ['id' => $provider->id])); | |
| 853 | +                throw new Exception(Craft::t("enupal-socializer", 'No Provider exists with the ID “{id}”', ['id' => $provider->id])); | |
| 854 | 854 | } | 
| 855 | 855 | } | 
| 856 | 856 | |
| @@ -31,7 +31,7 @@ discard block | ||
| 31 | 31 | $redirect = $this->getRedirectUrl(); | 
| 32 | 32 | |
| 33 | 33 |          if (is_null($provider)) { | 
| 34 | -            throw new \Exception(Craft::t('enupal-socializer','Provider not found or disabled')); | |
| 34 | +            throw new \Exception(Craft::t('enupal-socializer', 'Provider not found or disabled')); | |
| 35 | 35 | } | 
| 36 | 36 | |
| 37 | 37 | $redirectUrl = $redirect ?? Craft::$app->getRequest()->referrer; | 
| @@ -40,8 +40,8 @@ discard block | ||
| 40 | 40 | $adapter = $provider->getAdapter(); | 
| 41 | 41 | |
| 42 | 42 |          try { | 
| 43 | -            if ($adapter->authenticate()){ | |
| 44 | -                if (!Socializer::$app->providers->loginOrRegisterUser($provider)){ | |
| 43 | +            if ($adapter->authenticate()) { | |
| 44 | +                if (!Socializer::$app->providers->loginOrRegisterUser($provider)) { | |
| 45 | 45 |                      Craft::$app->getSession()->setError(Craft::t('enupal-socializer', "Unable to authenticate user")); | 
| 46 | 46 | } | 
| 47 | 47 | } | 
| @@ -62,7 +62,7 @@ discard block | ||
| 62 | 62 |      { | 
| 63 | 63 |          $redirect = Craft::$app->getRequest()->getParam('redirect'); | 
| 64 | 64 | |
| 65 | -        if ($redirect){ | |
| 65 | +        if ($redirect) { | |
| 66 | 66 | $redirect = UrlHelper::siteUrl($redirect); | 
| 67 | 67 | } | 
| 68 | 68 | |
| @@ -80,7 +80,7 @@ discard block | ||
| 80 | 80 | $redirectUrl = Craft::$app->getSession()->get(self::SESSION_REDIRECT_URL); | 
| 81 | 81 | $user = Craft::$app->getUser()->getIdentity(); | 
| 82 | 82 | |
| 83 | -        if ($user){ | |
| 83 | +        if ($user) { | |
| 84 | 84 | $variables['user'] = $user; | 
| 85 | 85 | $redirectUrl = Craft::$app->getView()->renderString($redirectUrl, $variables); | 
| 86 | 86 | } | 
| @@ -103,11 +103,11 @@ discard block | ||
| 103 | 103 | $providerHandle = Craft::$app->getSession()->get(self::SESSION_PROVIDER_HANDLE); | 
| 104 | 104 | $provider = Socializer::$app->providers->getProviderByHandle($providerHandle); | 
| 105 | 105 | |
| 106 | -        if (is_null($provider)){ | |
| 107 | -            throw new \Exception(Craft::t('enupal-socializer','Provider not found or disabled')); | |
| 106 | +        if (is_null($provider)) { | |
| 107 | +            throw new \Exception(Craft::t('enupal-socializer', 'Provider not found or disabled')); | |
| 108 | 108 | } | 
| 109 | 109 | |
| 110 | -        if (!Socializer::$app->providers->loginOrRegisterUser($provider)){ | |
| 110 | +        if (!Socializer::$app->providers->loginOrRegisterUser($provider)) { | |
| 111 | 111 |              Craft::$app->getSession()->setError(Craft::t('enupal-socializer', "Unable to authenticate user")); | 
| 112 | 112 | } | 
| 113 | 113 | |
| @@ -45,8 +45,7 @@ | ||
| 45 | 45 |                      Craft::$app->getSession()->setError(Craft::t('enupal-socializer', "Unable to authenticate user")); | 
| 46 | 46 | } | 
| 47 | 47 | } | 
| 48 | - } | |
| 49 | -        catch (\Exception $e) { | |
| 48 | +        } catch (\Exception $e) { | |
| 50 | 49 | Craft::error($e->getMessage(), __METHOD__); | 
| 51 | 50 | } | 
| 52 | 51 | |
| @@ -25,7 +25,7 @@ discard block | ||
| 25 | 25 |      { | 
| 26 | 26 | $this->requirePostRequest(); | 
| 27 | 27 |          $settings = Craft::$app->getRequest()->getBodyParam('settings'); | 
| 28 | -        $message = Craft::t('enupal-socializer','Settings saved.'); | |
| 28 | +        $message = Craft::t('enupal-socializer', 'Settings saved.'); | |
| 29 | 29 | |
| 30 | 30 | $plugin = Socializer::$app->settings->getPlugin(); | 
| 31 | 31 | $settingsModel = $plugin->getSettings(); | 
| @@ -34,7 +34,7 @@ discard block | ||
| 34 | 34 | |
| 35 | 35 |          if (!Socializer::$app->settings->saveSettings($settingsModel)) { | 
| 36 | 36 | |
| 37 | -            Craft::$app->getSession()->setError(Craft::t('enupal-socializer','Couldn’t save settings.')); | |
| 37 | +            Craft::$app->getSession()->setError(Craft::t('enupal-socializer', 'Couldn’t save settings.')); | |
| 38 | 38 | |
| 39 | 39 | // Send the settings back to the template | 
| 40 | 40 | Craft::$app->getUrlManager()->setRouteParams([ | 
| @@ -98,11 +98,11 @@ | ||
| 98 | 98 | return array_merge($parent, [ | 
| 99 | 99 | 'subnav' => [ | 
| 100 | 100 | 'providers' => [ | 
| 101 | -                    "label" => Craft::t('enupal-socializer',"Providers"), | |
| 101 | +                    "label" => Craft::t('enupal-socializer', "Providers"), | |
| 102 | 102 | "url" => 'enupal-socializer/providers' | 
| 103 | 103 | ], | 
| 104 | 104 | 'settings' => [ | 
| 105 | -                    "label" => Craft::t('enupal-socializer',"Settings"), | |
| 105 | +                    "label" => Craft::t('enupal-socializer', "Settings"), | |
| 106 | 106 | "url" => 'enupal-socializer/settings' | 
| 107 | 107 | ] | 
| 108 | 108 | ] | 
| @@ -28,15 +28,15 @@ | ||
| 28 | 28 |      { | 
| 29 | 29 |          if ($object->type != Apple::class) { | 
| 30 | 30 |              if ($object->enabled && !$object->clientId) { | 
| 31 | -                $this->addError($object, $attribute, Craft::t('enupal-socializer','Client ID cannot be blank')); | |
| 31 | +                $this->addError($object, $attribute, Craft::t('enupal-socializer', 'Client ID cannot be blank')); | |
| 32 | 32 | } | 
| 33 | 33 | |
| 34 | 34 |              if ($object->enabled && !$object->clientSecret) { | 
| 35 | -                $this->addError($object, 'clientSecret', Craft::t('enupal-socializer','Client Secret cannot be blank')); | |
| 35 | +                $this->addError($object, 'clientSecret', Craft::t('enupal-socializer', 'Client Secret cannot be blank')); | |
| 36 | 36 | } | 
| 37 | -        }else if ($object->type === Apple::class && $object->enabled) { | |
| 37 | +        } else if ($object->type === Apple::class && $object->enabled) { | |
| 38 | 38 |              if (!Socializer::$app->settings->validateAppleSettings()) { | 
| 39 | -                $this->addError($object, 'enabled', Craft::t('enupal-socializer','Unable to process the Apple settings from the config file')); | |
| 39 | +                $this->addError($object, 'enabled', Craft::t('enupal-socializer', 'Unable to process the Apple settings from the config file')); | |
| 40 | 40 | } | 
| 41 | 41 | } | 
| 42 | 42 | |
| @@ -34,7 +34,7 @@ | ||
| 34 | 34 |              if ($object->enabled && !$object->clientSecret) { | 
| 35 | 35 |                  $this->addError($object, 'clientSecret', Craft::t('enupal-socializer','Client Secret cannot be blank')); | 
| 36 | 36 | } | 
| 37 | -        }else if ($object->type === Apple::class && $object->enabled) { | |
| 37 | +        } else if ($object->type === Apple::class && $object->enabled) { | |
| 38 | 38 |              if (!Socializer::$app->settings->validateAppleSettings()) { | 
| 39 | 39 |                  $this->addError($object, 'enabled', Craft::t('enupal-socializer','Unable to process the Apple settings from the config file')); | 
| 40 | 40 | } | 
| @@ -15,5 +15,5 @@ | ||
| 15 | 15 | // Disable CSRF validation for the entire controller | 
| 16 | 16 | public $enableCsrfValidation = false; | 
| 17 | 17 | |
| 18 | - protected array|int|bool $allowAnonymous = true; | |
| 18 | + protected array | int | bool $allowAnonymous = true; | |
| 19 | 19 | } |