Completed
Pull Request — 1.x (#627)
by Dylan
08:40
created

UserControllerFactory::createService()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 24
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 2 Features 0
Metric Value
c 3
b 2
f 0
dl 0
loc 24
rs 8.9713
cc 1
eloc 11
nc 1
nop 1
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: Clayton Daley
5
 * Date: 5/6/2015
6
 * Time: 6:50 PM
7
 */
8
9
namespace ZfcUser\Factory\Controller;
10
11
use Zend\Mvc\Controller\ControllerManager;
12
use Zend\ServiceManager\FactoryInterface;
13
use Zend\ServiceManager\ServiceLocatorInterface;
14
use ZfcUser\Controller\RedirectCallback;
15
use ZfcUser\Controller\UserController;
16
use ZfcUser\Form\ChangeEmail;
17
use ZfcUser\Form\ChangePassword;
18
use ZfcUser\Form\Login;
19
use ZfcUser\Form\Register;
20
use ZfcUser\Options\ModuleOptions;
21
use ZfcUser\Service\User;
22
23
class UserControllerFactory implements FactoryInterface
24
{
25
26
    /**
27
     * Create service
28
     *
29
     * @param ServiceLocatorInterface $controllerManager
30
     * @return mixed
31
     */
32
    public function createService(ServiceLocatorInterface $controllerManager)
33
    {
34
        /* @var ControllerManager $controllerManager */
35
        $serviceManager = $controllerManager->getServiceLocator();
36
        /* @var RedirectCallback $redirectCallback */
37
        $redirectCallback = $serviceManager->get('zfcuser_redirect_callback');
38
        /** @var User $userService */
39
        $userService = $serviceManager->get('zfcuser_user_service');
40
        /** @var Login $loginForm */
41
        $loginForm = $serviceManager->get('FormElementManager')->get('zfcuser_login_form');
42
        /** @var Register $registerForm */
43
        $registerForm = $serviceManager->get('FormElementManager')->get('zfcuser_register_form');
44
        /** @var ChangePassword $changePasswordForm */
45
        $changePasswordForm = $serviceManager->get('FormElementManager')->get('zfcuser_change_password_form');
46
        /** @var ChangeEmail $changeEmailForm */
47
        $changeEmailForm = $serviceManager->get('FormElementManager')->get('zfcuser_change_email_form');
48
        /** @var ModuleOptions $options */
49
        $options = $serviceManager->get('zfcuser_module_options');
50
51
        /* @var UserController $controller */
52
        $controller = new UserController($userService, $loginForm, $registerForm, $changePasswordForm, $changeEmailForm, $options, $redirectCallback);
53
54
        return $controller;
55
    }
56
}
57