Code Duplication    Length = 28-41 lines in 17 locations

module/Auth/src/Acl/Controller/Plugin/AclFactory.php 1 location

@@ 20-52 (lines=33) @@
17
 * Class AclFactory
18
 * @package Acl\Controller\Plugin
19
 */
20
class AclFactory implements FactoryInterface
21
{
22
23
    /**
24
     * Create an object
25
     *
26
     * @param  ContainerInterface $container
27
     * @param  string             $requestedName
28
     * @param  null|array         $options
29
     *
30
     * @return object
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
        $acl      = $container->get('acl');
39
        $auth     = $container->get('AuthenticationService');
40
41
        $plugin = new Acl($acl, $auth->getUser());
42
        return $plugin;
43
    }
44
45
    /* (non-PHPdoc)
46
     * @see \Zend\ServiceManager\FactoryInterface::createService()
47
     */
48
    public function createService(\Zend\ServiceManager\ServiceLocatorInterface $serviceLocator)
49
    {
50
        return $this($serviceLocator->getServiceLocator(), Acl::class);
51
    }
52
}
53

module/Auth/src/Acl/Factory/View/Helper/AclFactory.php 1 location

@@ 21-53 (lines=33) @@
18
 * Class AclFactory
19
 * @package Acl\View\Helper
20
 */
21
class AclFactory implements FactoryInterface
22
{
23
24
    /**
25
     * Create an object
26
     *
27
     * @param  ContainerInterface $container
28
     * @param  string             $requestedName
29
     * @param  null|array         $options
30
     *
31
     * @return object
32
     * @throws ServiceNotFoundException if unable to resolve the service.
33
     * @throws ServiceNotCreatedException if an exception is raised when
34
     *     creating a service.
35
     * @throws ContainerException if any other error occurs
36
     */
37
    public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
38
    {
39
        $plugins  = $container->get('controllerpluginmanager');
40
        $acl      = $plugins->get('acl');
41
42
        $helper = new Acl($acl);
43
        return $helper;
44
    }
45
46
    /* (non-PHPdoc)
47
     * @see \Zend\ServiceManager\FactoryInterface::createService()
48
     */
49
    public function createService(\Zend\ServiceManager\ServiceLocatorInterface $serviceLocator)
50
    {
51
        return $this($serviceLocator->getServiceLocator(), Acl::class);
52
    }
53
}
54

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

@@ 21-61 (lines=41) @@
18
use Zend\ServiceManager\FactoryInterface;
19
use Zend\ServiceManager\ServiceLocatorInterface;
20
21
class ForgotPasswordControllerFactory implements FactoryInterface
22
{
23
    /**
24
     * Create a ForgotPasswordController controller
25
     *
26
     * @param  ContainerInterface $container
27
     * @param  string             $requestedName
28
     * @param  null|array         $options
29
     *
30
     * @return ForgotPasswordController
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 $form    Form\ForgotPassword
40
         * @var $service Service\ForgotPassword
41
         * @var $logger  LoggerInterface
42
         */
43
        $form = $container->get('Auth\Form\ForgotPassword');
44
        $service = $container->get('Auth\Service\ForgotPassword');
45
        $logger = $container->get('Core/Log');
46
47
        return new ForgotPasswordController($form, $service, $logger);
48
    }
49
50
    /**
51
     * Create service
52
     *
53
     * @param ServiceLocatorInterface $serviceLocator
54
     *
55
     * @return ForgotPasswordController
56
     */
57
    public function createService(ServiceLocatorInterface $serviceLocator)
58
    {
59
        return $this($serviceLocator->getServiceLocator(), ForgotPasswordController::class);
60
    }
61
}
62

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

@@ 18-53 (lines=36) @@
15
use Zend\ServiceManager\ServiceLocatorInterface;
16
use Zend\Form\FormElementManager;
17
18
class LoginFactory implements FactoryInterface
19
{
20
    /**
21
     * Create a Login form
22
     *
23
     * @param  ContainerInterface $container
24
     * @param  string             $requestedName
25
     * @param  null|array         $options
26
     *
27
     * @return Login
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 LoginInputFilter $filter */
36
        $filter = $container->get('Auth\Form\LoginInputFilter');
37
        $form = new Login(null, array());
38
        $form->setInputfilter($filter);
39
        return $form;
40
    }
41
42
    /**
43
     * Create service
44
     *
45
     * @param ServiceLocatorInterface $serviceLocator
46
     *
47
     * @return Login
48
     */
49
    public function createService(ServiceLocatorInterface $serviceLocator)
50
    {
51
        return $this($serviceLocator->getServiceLocator(), Login::class);
52
    }
53
}
54

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

@@ 17-46 (lines=30) @@
14
use Zend\ServiceManager\ServiceLocatorInterface;
15
use Auth\Form\UserStatusFieldset;
16
17
class UserStatusFieldsetFactory implements FactoryInterface
18
{
19
    /**
20
     * Create an UserStatusFieldset
21
     *
22
     * @param  ContainerInterface $container
23
     * @param  string             $requestedName
24
     * @param  null|array         $options
25
     *
26
     * @return UserStatusFieldset
27
     * @throws ServiceNotFoundException if unable to resolve the service.
28
     * @throws ServiceNotCreatedException if an exception is raised when
29
     *     creating a service.
30
     * @throws ContainerException if any other error occurs
31
     */
32
    public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
33
    {
34
        $translator = $container->get('Translator');
35
        $statusOptions = (new \Auth\Entity\Status())->getOptions($translator);
36
        $fieldset = new UserStatusFieldset();
37
        $fieldset->setStatusOptions($statusOptions);
38
39
        return $fieldset;
40
    }
41
42
    public function createService(ServiceLocatorInterface $serviceLocator)
43
    {
44
        return $this($serviceLocator->getServiceLocator(), UserStatusFieldset::class);
45
    }
46
}
47

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

@@ 21-61 (lines=41) @@
18
use Zend\ServiceManager\FactoryInterface;
19
use Zend\ServiceManager\ServiceLocatorInterface;
20
21
class RegisterFactory implements FactoryInterface
22
{
23
    /**
24
     * Create a Register service
25
     *
26
     * @param  ContainerInterface $container
27
     * @param  string             $requestedName
28
     * @param  null|array         $options
29
     *
30
     * @return Register
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
        /* @var Repository\User $userRepository */
39
        $userRepository = $container->get('repositories')->get('Auth/User');
40
41
        /* @var \Core\Mail\MailService $mailService */
42
        $mailService = $container->get('Core/MailService');
43
44
        /* @var \Core\Options\ModuleOptions $config */
45
        $config = $container->get('Core/Options');
46
47
        return new Register($userRepository, $mailService, $config);
48
    }
49
50
    /**
51
     * Create service
52
     *
53
     * @param ServiceLocatorInterface $serviceLocator
54
     *
55
     * @return Register
56
     */
57
    public function createService(ServiceLocatorInterface $serviceLocator)
58
    {
59
        return $this($serviceLocator, Register::class);
60
    }
61
}
62

module/Core/src/Core/Factory/Filter/HtmlAbsPathFilterFactory.php 1 location

@@ 18-47 (lines=30) @@
15
use Zend\ServiceManager\ServiceLocatorInterface;
16
use Core\Filter\HtmlAbsPathFilter;
17
18
class HtmlAbsPathFilterFactory implements FactoryInterface
19
{
20
    /**
21
     * Create an HtmlAbsPathFilter filter
22
     *
23
     * @param  ContainerInterface $container
24
     * @param  string             $requestedName
25
     * @param  null|array         $options
26
     *
27
     * @return HtmlAbsPathFilter
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 \Zend\ServiceManager\AbstractPluginManager $serviceLocator */
36
        $request = $container->get('request');
37
        $uri = $request->getUri();
38
        $filter = new HtmlAbsPathFilter();
39
        $filter->setUri($uri);
40
        return $filter;
41
    }
42
43
    public function createService(ServiceLocatorInterface $serviceLocator)
44
    {
45
        return $this($serviceLocator->getServiceLocator(), HtmlAbsPathFilter::class);
46
    }
47
}
48

module/Core/src/Core/Factory/View/Helper/SocialButtonsFactory.php 1 location

@@ 18-51 (lines=34) @@
15
use Zend\ServiceManager\ServiceLocatorInterface;
16
use Core\View\Helper\SocialButtons;
17
18
class SocialButtonsFactory implements FactoryInterface {
19
20
    /**
21
     * Create an SocialButtons view helper
22
     *
23
     * @param  ContainerInterface $container
24
     * @param  string             $requestedName
25
     * @param  null|array         $options
26
     *
27
     * @return SocialButtons
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 $serviceLocator \Zend\View\HelperPluginManager */
36
        $options = $container->get('Auth/Options');
37
        $config = $container->get('Config');
38
        $helper = new SocialButtons($options,$config);
39
        return $helper;
40
    }
41
42
    /**
43
     * @param ServiceLocatorInterface $serviceLocator
44
     *
45
     * @return SocialButtons
46
     */
47
    public function createService(ServiceLocatorInterface $serviceLocator)
48
    {
49
        return $this($serviceLocator->getServiceLocator(), SocialButtons::class);
50
    }
51
}
52
53

module/Cv/src/Cv/Factory/Form/SearchFormFieldsetFactory.php 1 location

@@ 18-45 (lines=28) @@
15
use Zend\ServiceManager\FactoryInterface;
16
use Zend\ServiceManager\ServiceLocatorInterface;
17
18
class SearchFormFieldsetFactory implements FactoryInterface
19
{
20
    /**
21
     * Create a SearchFormFieldset form
22
     *
23
     * @param  ContainerInterface $container
24
     * @param  string             $requestedName
25
     * @param  null|array         $options
26
     *
27
     * @return SearchFormFieldset
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 \Geo\Options\ModuleOptions $options */
36
        $options = $container->get('Geo/Options');
37
        $fs = new SearchFormFieldset(null, ['location_engine_type' => $options->getPlugin()]);
38
        return $fs;
39
    }
40
41
    public function createService(ServiceLocatorInterface $serviceLocator)
42
    {
43
        return $this($serviceLocator->getServiceLocator(), SearchFormFieldset::class);
44
    }
45
}

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

@@ 24-60 (lines=37) @@
21
 * @author Mathias Gelhausen <[email protected]>
22
 * @todo write test
23
 */
24
class AssignUserControllerFactory implements FactoryInterface
25
{
26
27
    /**
28
     * Create an object
29
     *
30
     * @param  ContainerInterface $container
31
     * @param  string             $requestedName
32
     * @param  null|array         $options
33
     *
34
     * @return AssignUserController
35
     */
36
    public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
37
    {
38
        $repositories = $container->get('repositories');
39
        $repository = $repositories->get('Jobs');
40
        $controller = new AssignUserController($repository);
41
42
        return $controller;
43
    }
44
45
    /**
46
     * Create service
47
     *
48
     * @param ServiceLocatorInterface $serviceLocator
49
     *
50
     * @return mixed
51
     */
52
    public function createService(ServiceLocatorInterface $serviceLocator)
53
    {
54
        return $this($serviceLocator->getServiceLocator(), AssignUserController::class);
55
    }
56
}
57

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

@@ 18-53 (lines=36) @@
15
use Zend\ServiceManager\FactoryInterface;
16
use Zend\ServiceManager\ServiceLocatorInterface;
17
18
class ManageControllerFactory implements FactoryInterface
19
{
20
    /**
21
     * Create an object
22
     *
23
     * @param  ContainerInterface $container
24
     * @param  string             $requestedName
25
     * @param  null|array         $options
26
     *
27
     * @return object
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
        $auth = $container->get('AuthenticationService');
36
        /* @var RepositoryService     $repositoryService */
37
        $repositoryService =    $container->get('repositories');
38
        $translator =    $container->get('translator');
39
        return new ManageController($auth, $repositoryService, $translator);
40
    }
41
42
    /**
43
     * Injects all needed services into the ManageController
44
     *
45
     * @param ServiceLocatorInterface $serviceLocator
46
     *
47
     * @return ManageController
48
     */
49
    public function createService(ServiceLocatorInterface $serviceLocator)
50
    {
51
        return $this($serviceLocator->getServiceLocator(), ManageController::class);
52
    }
53
}
54

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

@@ 19-57 (lines=39) @@
16
use Zend\ServiceManager\FactoryInterface;
17
use Zend\ServiceManager\ServiceLocatorInterface;
18
19
class TemplateControllerFactory implements FactoryInterface
20
{
21
22
    /**
23
     * Create an object
24
     *
25
     * @param  ContainerInterface $container
26
     * @param  string             $requestedName
27
     * @param  null|array         $options
28
     *
29
     * @return object
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
        /**
38
         * @var $jobRepository Repository\Job
39
         */
40
        $jobRepository = $container->get('repositories')->get('Jobs/Job');
41
        $options = $container->get('Jobs/Options');
42
43
        return new TemplateController($jobRepository, $options);
44
    }
45
46
    /**
47
     * Injects all needed services into the TemplateController
48
     *
49
     * @param ServiceLocatorInterface $serviceLocator
50
     *
51
     * @return TemplateController
52
     */
53
    public function createService(ServiceLocatorInterface $serviceLocator)
54
    {
55
        return $this($serviceLocator->getServiceLocator(), TemplateController::class);
56
    }
57
}
58

module/Jobs/src/Jobs/Factory/Filter/ChannelPricesFactory.php 1 location

@@ 22-59 (lines=38) @@
19
 * 
20
 * @author Mathias Gelhausen <[email protected]>
21
 */
22
class ChannelPricesFactory implements FactoryInterface
23
{
24
    protected $filterClass = '\Jobs\Filter\ChannelPrices';
25
26
    /**
27
     * Create an object
28
     *
29
     * @param  ContainerInterface $container
30
     * @param  string             $requestedName
31
     * @param  null|array         $options
32
     *
33
     * @return object
34
     * @throws ServiceNotFoundException if unable to resolve the service.
35
     * @throws ServiceNotCreatedException if an exception is raised when
36
     *     creating a service.
37
     * @throws ContainerException if any other error occurs
38
     */
39
    public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
40
    {
41
        $providerOptions = $container->get('Jobs/Options/Provider');
42
        $class = $this->filterClass;
43
        $filter = new $class($providerOptions);
44
45
        return $filter;
46
    }
47
48
    /**
49
     * Create service
50
     *
51
     * @param ServiceLocatorInterface $serviceLocator
52
     *
53
     * @return mixed
54
     */
55
    public function createService(ServiceLocatorInterface $serviceLocator)
56
    {
57
        return $this($serviceLocator->getServiceLocator(), JobboardSearch::class);
58
    }
59
}
60

module/Jobs/src/Jobs/Factory/Model/ApiJobDehydratorFactory.php 1 location

@@ 23-58 (lines=36) @@
20
 *
21
 * @author Carsten Bleek <[email protected]>
22
 */
23
class ApiJobDehydratorFactory implements FactoryInterface
24
{
25
26
    /**
27
     * Create an object
28
     *
29
     * @param  ContainerInterface $container
30
     * @param  string             $requestedName
31
     * @param  null|array         $options
32
     *
33
     * @return object
34
     * @throws ServiceNotFoundException if unable to resolve the service.
35
     * @throws ServiceNotCreatedException if an exception is raised when
36
     *     creating a service.
37
     * @throws ContainerException if any other error occurs
38
     */
39
    public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
40
    {
41
        $viewManager = $container->get('ViewHelperManager');
42
        $urlHelper = $viewManager->get('url');
43
        $apiJobDehydrator = new ApiJobDehydrator();
44
        $apiJobDehydrator->setUrl($urlHelper);
45
        return $apiJobDehydrator;
46
    }
47
48
    /**
49
     * @param ServiceLocatorInterface $serviceLocator
50
     *
51
     * @return ApiJobDehydrator
52
     */
53
    public function createService(ServiceLocatorInterface $serviceLocator)
54
    {
55
;
56
        return $this($serviceLocator, ApiJobDehydrator::class);
57
    }
58
}
59

module/Jobs/src/Jobs/Factory/Repository/Filter/PaginationAdminQueryFactory.php 1 location

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

module/Organizations/src/Organizations/Factory/Controller/TypeAHeadControllerFactory.php 1 location

@@ 19-52 (lines=34) @@
16
use Zend\ServiceManager\FactoryInterface;
17
use Zend\ServiceManager\ServiceLocatorInterface;
18
19
class TypeAHeadControllerFactory implements FactoryInterface
20
{
21
    /**
22
     * Create a TypeAHeadController controller
23
     *
24
     * @param  ContainerInterface $container
25
     * @param  string             $requestedName
26
     * @param  null|array         $options
27
     *
28
     * @return TypeAHeadController
29
     */
30
    public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
31
    {
32
        /**
33
         * @var $organizationRepository Repository\Organization
34
         */
35
        $organizationRepository = $container->get('repositories')->get('Organizations/Organization');
36
37
        return new TypeAHeadController($organizationRepository);
38
    }
39
40
    /**
41
     * Create service
42
     *
43
     * @param ServiceLocatorInterface $serviceLocator
44
     *
45
     * @return TypeAHeadController
46
     */
47
    public function createService(ServiceLocatorInterface $serviceLocator)
48
    {
49
        /** @var ControllerManager $serviceLocator */
50
        return $this($serviceLocator->getServiceLocator(), TypeAHeadController::class);
51
    }
52
}
53

module/Core/src/Core/Factory/View/Helper/AjaxUrlFactory.php 1 location

@@ 25-57 (lines=33) @@
22
 * @author Mathias Gelhausen <[email protected]>
23
 * @since 0,29
24
 */
25
class AjaxUrlFactory implements FactoryInterface
26
{
27
    /**
28
     * Create service
29
     *
30
     * @param ContainerInterface $container
31
     * @param string             $requestedName
32
     * @param array              $options
33
     *
34
     * @return AjaxUrl
35
     */
36
    public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
37
    {
38
        $request = $container->get('Request');
39
        $basepath = $request->getBasePath();
40
        $helper = new AjaxUrl($basepath);
41
42
        return $helper;
43
    }
44
45
    /**
46
     * Create service
47
     *
48
     * @param ServiceLocatorInterface|AbstractPluginManager $serviceLocator
49
     *
50
     * @return AjaxUrl
51
     * @deprecated use __invoke()
52
     */
53
    public function createService(ServiceLocatorInterface $serviceLocator)
54
    {
55
        return $this($serviceLocator->getServiceLocator(), AjaxUrl::class);
56
    }
57
}