1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* YAWIK |
4
|
|
|
* |
5
|
|
|
* @filesource |
6
|
|
|
* @copyright (c) 2013 - 2016 Cross Solution (http://cross-solution.de) |
7
|
|
|
* @license MIT |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
namespace Auth\Factory\Form; |
11
|
|
|
|
12
|
|
|
use Auth\Options\UserInfoFieldsetOptions; |
13
|
|
|
use Interop\Container\ContainerInterface; |
14
|
|
|
use Zend\ServiceManager\Factory\FactoryInterface; |
15
|
|
|
use Core\Entity\Hydrator\Strategy\FileUploadStrategy; |
16
|
|
|
use Core\Entity\Hydrator\EntityHydrator; |
17
|
|
|
use Core\Factory\Form\AbstractCustomizableFieldsetFactory; |
18
|
|
|
use Auth\Entity\UserImage; |
19
|
|
|
use Auth\Form\UserInfoFieldset; |
20
|
|
|
|
21
|
|
|
class UserInfoFieldsetFactory extends AbstractCustomizableFieldsetFactory implements FactoryInterface |
22
|
|
|
{ |
23
|
|
|
const OPTIONS_NAME = UserInfoFieldsetOptions::class; |
24
|
|
|
/** |
25
|
|
|
* Create an UserInfoFieldset. |
26
|
|
|
* |
27
|
|
|
* @param ContainerInterface $container |
28
|
|
|
* @param string $requestedName |
29
|
|
|
* @param null|array $options |
30
|
|
|
* |
31
|
|
|
* @return UserInfoFieldset |
32
|
|
|
*/ |
33
|
1 |
|
protected function createFormInstance(ContainerInterface $container, $requestedName, array $options = null) |
34
|
|
|
{ |
35
|
1 |
|
$user = $container->get('AuthenticationService')->getUser(); |
36
|
1 |
|
$fieldset = new UserInfoFieldset(); |
37
|
1 |
|
$imageEntity = new UserImage(); |
38
|
1 |
|
$imageEntity->setUser($user); |
39
|
1 |
|
$strategy = new FileUploadStrategy($imageEntity); |
40
|
1 |
|
$hydrator = new EntityHydrator(); |
41
|
1 |
|
$hydrator->addStrategy('image', $strategy); |
42
|
1 |
|
$fieldset->setHydrator($hydrator); |
43
|
1 |
|
return $fieldset; |
44
|
|
|
} |
45
|
|
|
} |
46
|
|
|
|