Code Duplication    Length = 30-43 lines in 10 locations

module/Auth/src/Auth/Factory/Controller/Plugin/UserSwitcherFactory.php 1 location

@@ 24-58 (lines=35) @@
21
 * @author Mathias Gelhausen <[email protected]>
22
 * @since 0.29
23
 */
24
class UserSwitcherFactory implements FactoryInterface
25
{
26
27
    /**
28
     * Create an UserSwitcher plugin.
29
     *
30
     * @param ContainerInterface $container
31
     * @param string             $requestedName
32
     * @param array              $options
33
     *
34
     * @return UserSwitcher
35
     */
36
    public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
37
    {
38
        $auth   = $container->get('AuthenticationService');
39
        $acl    = $container->get('ControllerPluginManager')->get('Acl');
40
        $plugin = new UserSwitcher($auth);
41
42
        $plugin->setAclPlugin($acl);
43
44
        return $plugin;
45
    }
46
47
    /**
48
     * Create an UserSwitcher plugin.
49
     *
50
     * @param \Zend\ServiceManager\AbstractPluginManager|ServiceLocatorInterface $serviceLocator
51
     *
52
     * @return UserSwitcher
53
     */
54
    public function createService(ServiceLocatorInterface $serviceLocator)
55
    {
56
        return $this($serviceLocator->getServiceLocator(), 'Auth/User/Switcher');
57
    }
58
}

module/Jobs/src/Jobs/Factory/Controller/ApiJobListByOrganizationControllerFactory.php 1 location

@@ 17-59 (lines=43) @@
14
use Zend\ServiceManager\FactoryInterface;
15
use Zend\ServiceManager\ServiceLocatorInterface;
16
17
class ApiJobListByOrganizationControllerFactory implements FactoryInterface
18
{
19
    /**
20
     * Create an object
21
     *
22
     * @param  ContainerInterface $container
23
     * @param  string             $requestedName
24
     * @param  null|array         $options
25
     *
26
     * @return object
27
     */
28
    public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
29
    {
30
        $repositories = $container->get('repositories');
31
32
        /** @var \Jobs\Repository\Job $jobRepository */
33
        $jobRepository = $repositories->get('Jobs');
34
35
        /** @var \Jobs\Model\ApiJobDehydrator $apiJobDehydrator */
36
        $apiJobDehydrator = $container->get('Jobs\Model\ApiJobDehydrator');
37
38
        $controller = new ApiJobListByOrganizationController($jobRepository, $apiJobDehydrator);
39
40
        return $controller;
41
    }
42
43
    /**
44
     * Create service
45
     *
46
     * @param ServiceLocatorInterface $serviceLocator
47
     *
48
     * @return ApiJobListByOrganizationController
49
     */
50
    public function createService(ServiceLocatorInterface $serviceLocator)
51
    {
52
        /* @var $serviceLocator \Zend\Mvc\Controller\PluginManager */
53
        return $this($serviceLocator->getServiceLocator(), ApiJobListByOrganizationController::class);
54
    }
55
}
56

module/Jobs/src/Jobs/Factory/Form/ActiveOrganizationSelectFactory.php 1 location

@@ 27-65 (lines=39) @@
24
 * @author Mathias Gelhausen <[email protected]>
25
 * @since 0.23
26
 */
27
class ActiveOrganizationSelectFactory implements FactoryInterface
28
{
29
    /**
30
     * Create an object
31
     *
32
     * @param  ContainerInterface $container
33
     * @param  string             $requestedName
34
     * @param  null|array         $options
35
     *
36
     * @return object
37
     * @throws ServiceNotFoundException if unable to resolve the service.
38
     * @throws ServiceNotCreatedException if an exception is raised when
39
     *     creating a service.
40
     * @throws ContainerException if any other error occurs
41
     */
42
    public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
43
    {
44
        /* @var $serviceLocator \Zend\ServiceManager\AbstractPluginManager
45
         * @var $jobsRepository \Jobs\Repository\Job
46
         */
47
        $repositories   = $container->get('repositories');
48
        $jobsRepository = $repositories->get('Jobs');
49
        $organizations  = $jobsRepository->findActiveOrganizations();
50
        $select         = new OrganizationSelect();
51
52
        $select->setSelectableOrganizations($organizations);
53
54
        return $select;
55
56
    }
57
58
    /**
59
     * Creates the organization select box.
60
     */
61
    public function createService(ServiceLocatorInterface $serviceLocator)
62
    {
63
        return $this($serviceLocator->getServiceLocator(), OrganizationSelect::class);
64
    }
65
}
66

module/Jobs/src/Jobs/Factory/Controller/Plugin/InitializeJobFactory.php 1 location

@@ 18-50 (lines=33) @@
15
use Core\Repository\RepositoryService;
16
use Jobs\Controller\Plugin\InitializeJob;
17
18
class InitializeJobFactory implements FactoryInterface
19
{
20
21
    /**
22
     * Create an InitializeJob
23
     *
24
     * @param  ContainerInterface $container
25
     * @param  string             $requestedName
26
     * @param  null|array         $options
27
     *
28
     * @return InitializeJob
29
     */
30
    public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
31
    {
32
        /* @var $repositories RepositoryService */
33
        $repositories = $container->get('repositories');
34
        /* @var \Auth\AuthenticationService */
35
        $auth = $container->get('AuthenticationService');
36
        /* @var \Acl\Controller\Plugin\Acl */
37
        $acl = $container->get('ControllerPluginManager')->get('acl');
38
39
        $plugin = new InitializeJob($repositories, $auth, $acl);
40
        return $plugin;
41
    }
42
    public function createService(\Zend\ServiceManager\ServiceLocatorInterface $serviceLocator)
43
    {
44
        /* @var \Zend\Mvc\Controller\PluginManager $serviceLocator */
45
        return $this($serviceLocator->getServiceLocator(), InitializeJob::class);
46
    }
47
}
48

module/Applications/src/Applications/Factory/Listener/StatusChangeFactory.php 1 location

@@ 27-62 (lines=36) @@
24
 * @author Bleek Carsten <[email protected]>
25
 * @todo write test 
26
 */
27
class StatusChangeFactory implements FactoryInterface
28
{
29
    /**
30
     * Create a StatusChange listener
31
     *
32
     * @param  ContainerInterface $container
33
     * @param  string             $requestedName
34
     * @param  null|array         $options
35
     *
36
     * @return StatusChange
37
     * @throws ServiceNotFoundException if unable to resolve the service.
38
     * @throws ServiceNotCreatedException if an exception is raised when
39
     *     creating a service.
40
     * @throws ContainerException if any other error occurs
41
     */
42
    public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
43
    {
44
        $options         = $container->get('Applications/Options');
45
        $mailService     = $container->get('Core/MailService');
46
        $translator      = $container->get('translator');
47
        $listener        = new StatusChange($options, $mailService, $translator);
48
        return $listener;
49
    }
50
51
    /**
52
     * Create service
53
     *
54
     * @param ServiceLocatorInterface $serviceLocator
55
     *
56
     * @return mixed
57
     */
58
    public function createService(ServiceLocatorInterface $serviceLocator)
59
    {
60
        return $this($serviceLocator, StatusChange::class);
61
    }
62
}

module/Auth/src/Auth/Factory/Controller/PasswordControllerFactory.php 1 location

@@ 21-61 (lines=41) @@
18
use Zend\ServiceManager\FactoryInterface;
19
use Zend\ServiceManager\ServiceLocatorInterface;
20
21
class PasswordControllerFactory implements FactoryInterface
22
{
23
    /**
24
     * Create a PasswordController controller
25
     *
26
     * @param  ContainerInterface $container
27
     * @param  string             $requestedName
28
     * @param  null|array         $options
29
     *
30
     * @return PasswordController
31
     * @throws ServiceNotFoundException if unable to resolve the service.
32
     * @throws ServiceNotCreatedException if an exception is raised when
33
     *     creating a service.
34
     * @throws ContainerException if any other error occurs
35
     */
36
    public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
37
    {
38
        /**
39
         * @var AuthenticationService $authenticationService
40
         * @var Form\UserPassword     $form
41
         * @var RepositoryService     $repositoryService
42
         */
43
        $authenticationService = $container->get('AuthenticationService');
44
        $form = $container->get('forms')->get('user-password');
45
        $repositoryService = $container->get('repositories');
46
47
        return new PasswordController($authenticationService, $form, $repositoryService);
48
    }
49
50
    /**
51
     * Create service
52
     *
53
     * @param ServiceLocatorInterface $serviceLocator
54
     *
55
     * @return PasswordController
56
     */
57
    public function createService(ServiceLocatorInterface $serviceLocator)
58
    {
59
        return $this($serviceLocator->getServiceLocator(), PasswordController::class);
60
    }
61
}
62

module/Auth/src/Auth/Factory/Form/RegisterFactory.php 1 location

@@ 18-58 (lines=41) @@
15
use Zend\ServiceManager\ServiceLocatorInterface;
16
use Auth\Options\CaptchaOptions;
17
18
class RegisterFactory implements FactoryInterface
19
{
20
    /**
21
     * Create a Register form
22
     *
23
     * @param  ContainerInterface $container
24
     * @param  string             $requestedName
25
     * @param  null|array         $options
26
     *
27
     * @return Register
28
     * @throws ServiceNotFoundException if unable to resolve the service.
29
     * @throws ServiceNotCreatedException if an exception is raised when
30
     *     creating a service.
31
     * @throws ContainerException if any other error occurs
32
     */
33
    public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
34
    {
35
        /* @var RegisterInputFilter $filter */
36
        $filter = $container->get('Auth\Form\RegisterInputFilter');
37
38
        /* @var CaptchaOptions $config */
39
        $config = $container->get('Auth/CaptchaOptions');
40
41
        $form = new Register(null, $config);
42
        $form->setAttribute('id', 'registration');
43
        $form->setInputfilter($filter);
44
45
        return $form;
46
    }
47
    /**
48
     * Create service
49
     *
50
     * @param ServiceLocatorInterface $serviceLocator
51
     *
52
     * @return Register
53
     */
54
    public function createService(ServiceLocatorInterface $serviceLocator)
55
    {
56
        return $this($serviceLocator->getServiceLocator(), Register::class);
57
    }
58
}
59

module/Auth/src/Auth/Factory/Listener/MailForgotPasswordFactory.php 1 location

@@ 20-54 (lines=35) @@
17
/**
18
 * Factory for creating the Auth view helper.
19
 */
20
class MailForgotPasswordFactory implements FactoryInterface
21
{
22
    /**
23
     * Create a MailForgotPassword Listener
24
     *
25
     * @param  ContainerInterface $container
26
     * @param  string             $requestedName
27
     * @param  null|array         $options
28
     *
29
     * @return MailForgotPassword
30
     * @throws ServiceNotFoundException if unable to resolve the service.
31
     * @throws ServiceNotCreatedException if an exception is raised when
32
     *     creating a service.
33
     * @throws ContainerException if any other error occurs
34
     */
35
    public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
36
    {
37
        $options = $container->get('Auth\Options');
38
        $coreOptions = $container->get('Core\Options');
39
        $mailService = $container->get('Core\MailService');
40
        $listener = new MailForgotPassword($options, $mailService, $coreOptions);
41
        return $listener;
42
    }
43
    /**
44
     * Creates an instance of MailForgotPassword
45
     *
46
     * @param ServiceLocatorInterface $serviceLocator
47
     * @return \Auth\View\Helper\Auth
48
     * @see \Zend\ServiceManager\FactoryInterface::createService()
49
     */
50
    public function createService(ServiceLocatorInterface $serviceLocator)
51
    {
52
        return $this($serviceLocator, MailForgotPassword::class);
53
    }
54
}
55

module/Install/src/Factory/Controller/Plugin/UserCreatorFactory.php 1 location

@@ 24-59 (lines=36) @@
21
 * @author Mathias Gelhausen <[email protected]>
22
 * @since 0.20
23
 */
24
class UserCreatorFactory implements FactoryInterface
25
{
26
    /**
27
     * Create a UserCreator controller plugin
28
     *
29
     * @param  ContainerInterface $container
30
     * @param  string             $requestedName
31
     * @param  null|array         $options
32
     *
33
     * @return UserCreator
34
     */
35
    public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
36
    {
37
        $filters  = $container->get('FilterManager');
38
39
        $dbNameExctractor = $filters->get('Install/DbNameExtractor');
40
        $credentialFilter = $filters->get('Auth/CredentialFilter');
41
42
        $plugin = new UserCreator($dbNameExctractor, $credentialFilter);
43
44
        return $plugin;
45
    }
46
47
    /**
48
     * Creates a UserCreator plugin instance.
49
     *
50
     * @param ServiceLocatorInterface $serviceLocator Controller plugin manager
51
     *
52
     * @return UserCreator
53
     */
54
    public function createService(ServiceLocatorInterface $serviceLocator)
55
    {
56
        /* @var $serviceLocator \Zend\Mvc\Controller\PluginManager */
57
        return $this($serviceLocator->getServiceLocator(), UserCreator::class);
58
    }
59
}
60

module/Organizations/src/Organizations/Factory/Controller/Plugin/GetOrganizationHandlerFactory.php 1 location

@@ 18-47 (lines=30) @@
15
use Core\Repository\RepositoryService;
16
use Organizations\Controller\Plugin\GetOrganizationHandler;
17
18
class GetOrganizationHandlerFactory implements FactoryInterface {
19
20
    /**
21
     * Create a GetOrganizationHandler controller plugin
22
     *
23
     * @param  ContainerInterface $container
24
     * @param  string             $requestedName
25
     * @param  null|array         $options
26
     *
27
     * @return GetOrganizationHandler
28
     */
29
    public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
30
    {
31
        /* @var $repositories RepositoryService */
32
        $repositories = $container->get('repositories');
33
        /* @var \Auth\AuthenticationService */
34
        $auth = $container->get('AuthenticationService');
35
        /* @var \Acl\Controller\Plugin\Acl */
36
        $acl = $container->get('ControllerPluginManager')->get('acl');
37
38
        $plugin = new GetOrganizationHandler($repositories, $auth, $acl);
39
        return $plugin;
40
    }
41
42
    public function createService(\Zend\ServiceManager\ServiceLocatorInterface $serviceLocator)
43
    {
44
        /* @var $serviceLocator \Zend\Mvc\Controller\PluginManager */
45
        return $this($serviceLocator->getServiceLocator(), GetOrganizationHandler::class);
46
    }
47
}
48