Completed
Push — 1.0 ( 4b07bc...bb4e0d )
by David
06:01
created

ForgotYourPasswordInstaller   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
c 1
b 0
f 0
lcom 0
cbo 1
dl 0
loc 14
rs 10
1
<?php
2
3
namespace Mouf\Security\Password;
4
5
use Mouf\Actions\InstallUtils;
6
use Mouf\Html\Renderer\RendererUtils;
7
use Mouf\Installer\PackageInstallerInterface;
8
use Mouf\MoufManager;
9
10
class ForgotYourPasswordInstaller implements PackageInstallerInterface
11
{
12
    /**
13
     * (non-PHPdoc).
14
     *
15
     * @see \Mouf\Installer\PackageInstallerInterface::install()
16
     */
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'] = true;
32
        $configManager->setDefinedConstants($configPhpConstants);
33
34
35
        // These instances are expected to exist when the installer is run.
36
        $defaultTranslationService = $moufManager->getInstanceDescriptor('defaultTranslationService');
37
        if ($moufManager->has('Mouf\\Security\\DAO\\SecurityUserDao')) {
38
            $Mouf_Security_DAO_SecurityUserDao = $moufManager->getInstanceDescriptor('Mouf\\Security\\DAO\\SecurityUserDao');
39
        } else {
40
            $Mouf_Security_DAO_SecurityUserDao = null;
41
        }
42
        $swiftMailer = $moufManager->getInstanceDescriptor('swiftMailer');
43
        $forgotYourPasswordMailTemplate = $moufManager->getInstanceDescriptor('forgotYourPasswordMailTemplate');
44
        $userService = $moufManager->getInstanceDescriptor('userService');
45
        $psr_errorLogLogger = $moufManager->getInstanceDescriptor('psr.errorLogLogger');
46
        $bootstrapTemplate = $moufManager->getInstanceDescriptor('bootstrapTemplate');
47
        $block_content = $moufManager->getInstanceDescriptor('block.content');
48
        $twigEnvironment = $moufManager->getInstanceDescriptor('twigEnvironment');
49
50
        // Let's create the instances.
51
        $Mouf_Security_Password_PasswordStrengthCheck = InstallUtils::getOrCreateInstance('Mouf\\Security\\Password\\PasswordStrengthCheck', 'Mouf\\Security\\Password\\PasswordStrengthCheck', $moufManager);
52
        $Mouf_Security_Password_ForgotYourPasswordService = InstallUtils::getOrCreateInstance('Mouf\\Security\\Password\\ForgotYourPasswordService', 'Mouf\\Security\\Password\\ForgotYourPasswordService', $moufManager);
53
        $Mouf_Security_Password_ForgotYourPasswordController = InstallUtils::getOrCreateInstance('Mouf\\Security\\Password\\ForgotYourPasswordController', 'Mouf\\Security\\Password\\ForgotYourPasswordController', $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
93
        // Let's rewrite the MoufComponents.php file to save the component
94
        $moufManager->rewriteMouf();
95
    }
96
}
97