Completed
Push — develop ( 975a05...8c983c )
by
unknown
07:04
created

IndexControllerFactory::__invoke()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 3
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 Organizations\Factory\Controller;
11
12
use Interop\Container\ContainerInterface;
13
use Organizations\Controller\IndexController;
14
use Organizations\Repository;
15
use Organizations\Form;
16
use Zend\Mvc\Controller\ControllerManager;
17
use Zend\ServiceManager\FactoryInterface;
18
use Zend\ServiceManager\ServiceLocatorInterface;
19
20
class IndexControllerFactory implements FactoryInterface
21
{
22
    /**
23
     * Create a IndexController controller
24
     *
25
     * @param  ContainerInterface $container
26
     * @param  string             $requestedName
27
     * @param  null|array         $options
28
     *
29
     * @return IndexController
30
     */
31
    public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
32
    {
33
        $organizationRepository = $container->get('repositories')->get('Organizations/Organization');
34
35
        $form = new Form\Organizations(null);
36
37
        return new IndexController($form, $organizationRepository);
38
    }
39
40
    /**
41
     * Create service
42
     *
43
     * @param ServiceLocatorInterface $serviceLocator
44
     *
45
     * @return IndexController
46
     */
47
    public function createService(ServiceLocatorInterface $serviceLocator)
48
    {
49
        /** @var ControllerManager $serviceLocator */
50
        return $this($serviceLocator->getServiceLocator(), IndexController::class);
51
    }
52
}
53