|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* YAWIK |
|
4
|
|
|
* |
|
5
|
|
|
* @filesource |
|
6
|
|
|
* @license MIT |
|
7
|
|
|
* @copyright 2013 - 2016 Cross Solution <http://cross-solution.de> |
|
8
|
|
|
*/ |
|
9
|
|
|
|
|
10
|
|
|
/** */ |
|
11
|
|
|
namespace Organizations\Factory\Form; |
|
12
|
|
|
|
|
13
|
|
|
use Core\Entity\Hydrator\EntityHydrator; |
|
14
|
|
|
use Core\Form\Hydrator\Strategy\CollectionStrategy; |
|
15
|
|
|
use Interop\Container\ContainerInterface; |
|
16
|
|
|
use Zend\ServiceManager\FactoryInterface; |
|
17
|
|
|
use Zend\ServiceManager\ServiceLocatorInterface; |
|
18
|
|
|
use Organizations\Form\EmployeesFieldset; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* Creates an EmployeesFieldset and injects the needed javascript to the HeadScript View Helper |
|
22
|
|
|
* |
|
23
|
|
|
* @author Mathias Gelhausen <[email protected]> |
|
24
|
|
|
* @since 0.18 |
|
25
|
|
|
*/ |
|
26
|
|
|
class EmployeesFieldsetFactory implements FactoryInterface |
|
27
|
|
|
{ |
|
28
|
|
|
/** |
|
29
|
|
|
* Create a EmployeesFieldset fieldset |
|
30
|
|
|
* |
|
31
|
|
|
* @param ContainerInterface $container |
|
32
|
|
|
* @param string $requestedName |
|
33
|
|
|
* @param null|array $options |
|
34
|
|
|
* |
|
35
|
|
|
* @return EmployeesFieldset |
|
36
|
|
|
*/ |
|
37
|
|
|
public function __invoke(ContainerInterface $container, $requestedName, array $options = null) |
|
38
|
|
|
{ |
|
39
|
|
|
|
|
40
|
|
|
/* @var $headScript \Zend\View\Helper\HeadScript */ |
|
41
|
|
|
$helpers = $container->get('ViewHelperManager'); |
|
42
|
|
|
$headScript = $helpers->get('headscript'); |
|
43
|
|
|
$basePath = $helpers->get('basepath'); |
|
44
|
|
|
$fieldset = new EmployeesFieldset(); |
|
45
|
|
|
$hydrator = new EntityHydrator(); |
|
46
|
|
|
|
|
47
|
|
|
$hydrator->addStrategy('employees', new CollectionStrategy()); |
|
48
|
|
|
$fieldset->setHydrator($hydrator); |
|
49
|
|
|
|
|
50
|
|
|
$headScript->appendFile($basePath('Organizations/js/organizations.employees.js')); |
|
51
|
|
|
|
|
52
|
|
|
return $fieldset; |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* Creates fieldset |
|
57
|
|
|
* {@inheritdoc} |
|
58
|
|
|
* |
|
59
|
|
|
* @return EmployeesFieldset |
|
60
|
|
|
*/ |
|
61
|
|
|
public function createService(ServiceLocatorInterface $serviceLocator) |
|
62
|
|
|
{ |
|
63
|
|
|
/* @var $serviceLocator \Zend\ServiceManager\AbstractPluginManager */ |
|
64
|
|
|
return $this($serviceLocator->getServiceLocator(), EmployeesFieldset::class); |
|
65
|
|
|
} |
|
66
|
|
|
} |
|
67
|
|
|
|