Completed
Push — develop ( c09155...432462 )
by
unknown
16:18
created

ActiveOrganizationSelectFactory::createService()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 15
rs 9.4286
cc 1
eloc 8
nc 1
nop 1
1
<?php
2
/**
3
 * YAWIK
4
 *
5
 * @filesource
6
 * @license    MIT
7
 * @copyright  2013 - 2015 Cross Solution <http://cross-solution.de>
8
 */
9
10
/** */
11
namespace Jobs\Factory\Form;
12
13
use Jobs\Form\OrganizationSelect;
14
use Zend\ServiceManager\FactoryInterface;
15
use Zend\ServiceManager\ServiceLocatorInterface;
16
17
/**
18
 * Factory for the ActiveOrganization select box
19
 *
20
 * This creates an {@link \Jobs\Form\OrganizationSelect} with all organizations that are
21
 * currently associated to at least one "active" job entity.
22
 *
23
 * @author Mathias Gelhausen <[email protected]>
24
 * @since 0.23
25
 */
26
class ActiveOrganizationSelectFactory implements FactoryInterface
27
{
28
    /**
29
     * Creates the organization select box.
30
     *
31
     */
32
    public function createService(ServiceLocatorInterface $serviceLocator)
33
    {
34
        /* @var $serviceLocator \Zend\ServiceManager\AbstractPluginManager
35
         * @var $jobsRepository \Jobs\Repository\Job
36
         */
37
        $services       = $serviceLocator->getServiceLocator();
38
        $repositories   = $services->get('repositories');
39
        $jobsRepository = $repositories->get('Jobs');
40
        $organizations  = $jobsRepository->findActiveOrganizations();
41
        $select         = new OrganizationSelect();
42
43
        $select->setSelectableOrganizations($organizations);
44
45
        return $select;
46
    }
47
}
48