| Conditions | 21 |
| Paths | > 20000 |
| Total Lines | 104 |
| Code Lines | 66 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 17 | public static function install(MoufManager $moufManager) |
||
| 18 | { |
||
| 19 | // Let's create the renderer |
||
| 20 | RendererUtils::createPackageRenderer($moufManager, 'mouf/security.forgot-your-password'); |
||
| 21 | |||
| 22 | $configManager = $moufManager->getConfigManager(); |
||
| 23 | |||
| 24 | $constants = $configManager->getMergedConstants(); |
||
| 25 | |||
| 26 | if (!isset($constants['MAIL_FROM'])) { |
||
| 27 | $configManager->registerConstant('MAIL_FROM', 'string', 'ro-reply@localhost', "The 'from' value used when sending mails."); |
||
| 28 | } |
||
| 29 | |||
| 30 | $configPhpConstants = $configManager->getDefinedConstants(); |
||
| 31 | $configPhpConstants['MAIL_FROM'] = 'ro-reply@localhost'; |
||
| 32 | $configManager->setDefinedConstants($configPhpConstants); |
||
| 33 | |||
| 34 | // These instances are expected to exist when the installer is run. |
||
| 35 | $defaultTranslationService = $moufManager->getInstanceDescriptor('defaultTranslationService'); |
||
| 36 | if ($moufManager->has('Mouf\\Security\\DAO\\SecurityUserDao')) { |
||
| 37 | $Mouf_Security_DAO_SecurityUserDao = $moufManager->getInstanceDescriptor('Mouf\\Security\\DAO\\SecurityUserDao'); |
||
| 38 | } else { |
||
| 39 | $Mouf_Security_DAO_SecurityUserDao = null; |
||
| 40 | } |
||
| 41 | $swiftMailer = $moufManager->getInstanceDescriptor('swiftMailer'); |
||
| 42 | $userService = $moufManager->getInstanceDescriptor('userService'); |
||
| 43 | $psr_errorLogLogger = $moufManager->getInstanceDescriptor('psr.errorLogLogger'); |
||
| 44 | $bootstrapTemplate = $moufManager->getInstanceDescriptor('bootstrapTemplate'); |
||
| 45 | $block_content = $moufManager->getInstanceDescriptor('block.content'); |
||
| 46 | $twigEnvironment = $moufManager->getInstanceDescriptor('twigEnvironment'); |
||
| 47 | $cascadingLanguageDetection = $moufManager->getInstanceDescriptor('cascadingLanguageDetection'); |
||
| 48 | |||
| 49 | // Let's create the instances. |
||
| 50 | $Mouf_Security_Password_PasswordStrengthCheck = InstallUtils::getOrCreateInstance('Mouf\\Security\\Password\\PasswordStrengthCheck', 'Mouf\\Security\\Password\\PasswordStrengthCheck', $moufManager); |
||
| 51 | $Mouf_Security_Password_ForgotYourPasswordService = InstallUtils::getOrCreateInstance('Mouf\\Security\\Password\\ForgotYourPasswordService', 'Mouf\\Security\\Password\\ForgotYourPasswordService', $moufManager); |
||
| 52 | $Mouf_Security_Password_ForgotYourPasswordController = InstallUtils::getOrCreateInstance('Mouf\\Security\\Password\\ForgotYourPasswordController', 'Mouf\\Security\\Password\\ForgotYourPasswordController', $moufManager); |
||
| 53 | $forgotYourPasswordMailTemplate = InstallUtils::getOrCreateInstance('forgotYourPasswordMailTemplate', 'TheCodingMachine\\Mail\\Template\\SwiftTwigMailTemplate', $moufManager); |
||
| 54 | |||
| 55 | // Let's bind instances together. |
||
| 56 | if (!$Mouf_Security_Password_PasswordStrengthCheck->getConstructorArgumentProperty('translationService')->isValueSet()) { |
||
| 57 | $Mouf_Security_Password_PasswordStrengthCheck->getConstructorArgumentProperty('translationService')->setValue($defaultTranslationService); |
||
| 58 | } |
||
| 59 | if (!$Mouf_Security_Password_ForgotYourPasswordService->getConstructorArgumentProperty('forgetYourPasswordDao')->isValueSet()) { |
||
| 60 | $Mouf_Security_Password_ForgotYourPasswordService->getConstructorArgumentProperty('forgetYourPasswordDao')->setValue($Mouf_Security_DAO_SecurityUserDao); |
||
| 61 | } |
||
| 62 | if (!$Mouf_Security_Password_ForgotYourPasswordService->getConstructorArgumentProperty('swiftMailer')->isValueSet()) { |
||
| 63 | $Mouf_Security_Password_ForgotYourPasswordService->getConstructorArgumentProperty('swiftMailer')->setValue($swiftMailer); |
||
| 64 | } |
||
| 65 | if (!$Mouf_Security_Password_ForgotYourPasswordService->getConstructorArgumentProperty('mailTemplate')->isValueSet()) { |
||
| 66 | $Mouf_Security_Password_ForgotYourPasswordService->getConstructorArgumentProperty('mailTemplate')->setValue($forgotYourPasswordMailTemplate); |
||
| 67 | } |
||
| 68 | if (!$Mouf_Security_Password_ForgotYourPasswordService->getConstructorArgumentProperty('userService')->isValueSet()) { |
||
| 69 | $Mouf_Security_Password_ForgotYourPasswordService->getConstructorArgumentProperty('userService')->setValue($userService); |
||
| 70 | } |
||
| 71 | if (!$Mouf_Security_Password_ForgotYourPasswordController->getConstructorArgumentProperty('logger')->isValueSet()) { |
||
| 72 | $Mouf_Security_Password_ForgotYourPasswordController->getConstructorArgumentProperty('logger')->setValue($psr_errorLogLogger); |
||
| 73 | } |
||
| 74 | if (!$Mouf_Security_Password_ForgotYourPasswordController->getConstructorArgumentProperty('template')->isValueSet()) { |
||
| 75 | $Mouf_Security_Password_ForgotYourPasswordController->getConstructorArgumentProperty('template')->setValue($bootstrapTemplate); |
||
| 76 | } |
||
| 77 | if (!$Mouf_Security_Password_ForgotYourPasswordController->getConstructorArgumentProperty('content')->isValueSet()) { |
||
| 78 | $Mouf_Security_Password_ForgotYourPasswordController->getConstructorArgumentProperty('content')->setValue($block_content); |
||
| 79 | } |
||
| 80 | if (!$Mouf_Security_Password_ForgotYourPasswordController->getConstructorArgumentProperty('twig')->isValueSet()) { |
||
| 81 | $Mouf_Security_Password_ForgotYourPasswordController->getConstructorArgumentProperty('twig')->setValue($twigEnvironment); |
||
| 82 | } |
||
| 83 | if (!$Mouf_Security_Password_ForgotYourPasswordController->getConstructorArgumentProperty('forgotYourPasswordService')->isValueSet()) { |
||
| 84 | $Mouf_Security_Password_ForgotYourPasswordController->getConstructorArgumentProperty('forgotYourPasswordService')->setValue($Mouf_Security_Password_ForgotYourPasswordService); |
||
| 85 | } |
||
| 86 | if (!$Mouf_Security_Password_ForgotYourPasswordController->getConstructorArgumentProperty('userService')->isValueSet()) { |
||
| 87 | $Mouf_Security_Password_ForgotYourPasswordController->getConstructorArgumentProperty('userService')->setValue($userService); |
||
| 88 | } |
||
| 89 | if (!$Mouf_Security_Password_ForgotYourPasswordController->getConstructorArgumentProperty('passwordStrengthCheck')->isValueSet()) { |
||
| 90 | $Mouf_Security_Password_ForgotYourPasswordController->getConstructorArgumentProperty('passwordStrengthCheck')->setValue($Mouf_Security_Password_PasswordStrengthCheck); |
||
| 91 | } |
||
| 92 | if (!$forgotYourPasswordMailTemplate->getConstructorArgumentProperty('twig_Environment')->isValueSet()) { |
||
| 93 | $forgotYourPasswordMailTemplate->getConstructorArgumentProperty('twig_Environment')->setValue($twigEnvironment); |
||
| 94 | } |
||
| 95 | if (!$forgotYourPasswordMailTemplate->getConstructorArgumentProperty('twigPath')->isValueSet()) { |
||
| 96 | $forgotYourPasswordMailTemplate->getConstructorArgumentProperty('twigPath')->setValue('vendor/mouf/security.forgot-your-password/src/templates/forgotyourpasswordmail.twig'); |
||
| 97 | } |
||
| 98 | if (!$forgotYourPasswordMailTemplate->getSetterProperty('setFromAddresses')->isValueSet()) { |
||
| 99 | $forgotYourPasswordMailTemplate->getSetterProperty('setFromAddresses')->setValue('MAIL_FROM'); |
||
| 100 | $forgotYourPasswordMailTemplate->getSetterProperty('setFromAddresses')->setOrigin('config'); |
||
| 101 | } |
||
| 102 | |||
| 103 | if (!$moufManager->has('forgotYourPasswordTranslator')) { |
||
| 104 | $forgotYourPasswordTranslator = InstallUtils::getOrCreateInstance('forgotYourPasswordTranslator', 'Mouf\\Utils\\I18n\\Fine\\Translator\\FileTranslator', $moufManager); |
||
| 105 | |||
| 106 | if (!$forgotYourPasswordTranslator->getConstructorArgumentProperty('i18nMessagePath')->isValueSet()) { |
||
| 107 | $forgotYourPasswordTranslator->getConstructorArgumentProperty('i18nMessagePath')->setValue('vendor/mouf/security.forgot-your-password/ressources/'); |
||
| 108 | } |
||
| 109 | if (!$forgotYourPasswordTranslator->getConstructorArgumentProperty('languageDetection')->isValueSet()) { |
||
| 110 | $forgotYourPasswordTranslator->getConstructorArgumentProperty('languageDetection')->setValue($cascadingLanguageDetection); |
||
| 111 | } |
||
| 112 | |||
| 113 | $translators = $defaultTranslationService->getProperty('translators')->getValue(); |
||
| 114 | $translators[] = $forgotYourPasswordTranslator; |
||
| 115 | $defaultTranslationService->getProperty('translators')->setValue($translators); |
||
| 116 | } |
||
| 117 | |||
| 118 | // Let's rewrite the MoufComponents.php file to save the component |
||
| 119 | $moufManager->rewriteMouf(); |
||
| 120 | } |
||
| 121 | } |
||
| 122 |