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

AcceptInvitationHandlerFactory::__invoke()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 10

Duplication

Lines 14
Ratio 100 %

Importance

Changes 0
Metric Value
dl 14
loc 14
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 10
nc 1
nop 3
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\Controller\Plugin;
12
13
use Interop\Container\ContainerInterface;
14
use Organizations\Controller\Plugin\AcceptInvitationHandler;
15
use Zend\ServiceManager\FactoryInterface;
16
use Zend\ServiceManager\ServiceLocatorInterface;
17
18
/**
19
 * Factory for an InvitationHandler.
20
 *
21
 * @author Mathias Gelhausen <[email protected]>
22
 * @since  0.19
23
 */
24 View Code Duplication
class AcceptInvitationHandlerFactory implements FactoryInterface
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
25
{
26
27
    /**
28
     * Create a AcceptInvitationHandler controller plugin
29
     *
30
     * @param  ContainerInterface $container
31
     * @param  string             $requestedName
32
     * @param  null|array         $options
33
     *
34
     * @return AcceptInvitationHandler
35
     */
36
    public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
37
    {
38
        $repositories           = $container->get('repositories');
39
        $userRepository         = $repositories->get('Auth/User');
40
        $organizationRepository = $repositories->get('Organizations');
41
        $authenticationService  = $container->get('AuthenticationService');
42
43
        $plugin = new AcceptInvitationHandler();
44
        $plugin->setUserRepository($userRepository)
45
               ->setOrganizationRepository($organizationRepository)
46
               ->setAuthenticationService($authenticationService);
47
48
        return $plugin;
49
    }
50
51
    /**
52
     * Creates an AcceptInvitationHandler
53
     *
54
     * @param ServiceLocatorInterface $serviceLocator
55
     *
56
     * @return AcceptInvitationHandler
57
     */
58
    public function createService(ServiceLocatorInterface $serviceLocator)
59
    {
60
        /* @var $serviceLocator \Zend\Mvc\Controller\PluginManager */
61
        return $this($serviceLocator->getServiceLocator(), AcceptInvitationHandler::class);
62
    }
63
}
64