Completed
Push — 2.x ( a081e5 )
by Daniel
15:13
created

ChangeEmail::__invoke()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 1 Features 0
Metric Value
c 2
b 1
f 0
dl 0
loc 15
rs 9.4285
cc 1
eloc 9
nc 1
nop 3
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 Interop\Container\ContainerInterface;
12
use Interop\Container\Exception\ContainerException;
13
use Zend\Form\FormElementManager;
14
use Zend\ServiceManager\Exception\ServiceNotCreatedException;
15
use Zend\ServiceManager\Exception\ServiceNotFoundException;
16
use Zend\ServiceManager\Factory\FactoryInterface;
17
use Zend\ServiceManager\ServiceLocatorInterface;
18
use ZfcUser\Form;
19
use ZfcUser\Validator;
20
21
class ChangeEmail implements FactoryInterface
22
{
23
    public function __invoke(ContainerInterface $serviceManager, $requestedName, array $options = null)
24
    {
25
        $options = $serviceManager->get('zfcuser_module_options');
26
        $form = new Form\ChangeEmail(null, $options);
27
28
        $form->setInputFilter(new Form\ChangeEmailFilter(
29
            $options,
30
            new Validator\NoRecordExists(array(
31
                'mapper' => $serviceManager->get('zfcuser_user_mapper'),
32
                'key'    => 'email'
33
            ))
34
        ));
35
36
        return $form;
37
    }
38
}
39