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

ChangeEmail   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 6

Importance

Changes 4
Bugs 1 Features 0
Metric Value
wmc 1
c 4
b 1
f 0
lcom 0
cbo 6
dl 0
loc 24
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A createService() 0 21 1
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: Clayton Daley
5
 * Date: 3/10/2015
6
 * Time: 9:34 AM
7
 */
8
9
namespace ZfcUser\Factory\Form;
10
11
use Zend\Form\FormElementManager;
12
use Zend\ServiceManager\FactoryInterface;
13
use Zend\ServiceManager\ServiceLocatorInterface;
14
use ZfcUser\Form;
15
use ZfcUser\Options\AuthenticationOptionsInterface;
16
use ZfcUser\Validator;
17
18
class ChangeEmail implements FactoryInterface
19
{
20
    public function createService(ServiceLocatorInterface $formElementManager)
21
    {
22
        /** @var FormElementManager $formElementManager */
23
        $fem = $formElementManager;
24
        $sm = $formElementManager->getServiceLocator();
25
        /** @var AuthenticationOptionsInterface $options */
26
        $options = $sm->get('zfcuser_module_options');
27
        $form = new Form\ChangeEmail(null, $options);
28
        // Inject the FormElementManager to support custom FormElements
29
        $form->getFormFactory()->setFormElementManager($fem);
30
31
        $form->setInputFilter(new Form\ChangeEmailFilter(
32
            $options,
33
            new Validator\NoRecordExists(array(
34
                'mapper' => $sm->get('zfcuser_user_mapper'),
35
                'key' => 'email'
36
            ))
37
        ));
38
39
        return $form;
40
    }
41
}
42