Passed
Pull Request — 1.1 (#1122)
by Tim
07:39
created

LdapManagerFactory::visit()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 23
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 11
nc 1
nop 2
dl 0
loc 23
rs 9.9
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * AppserverIo\Appserver\Ldap\LdapManagerFactory
5
 *
6
 * NOTICE OF LICENSE
7
 *
8
 * This source file is subject to the Open Software License (OSL 3.0)
9
 * that is available through the world-wide-web at this URL:
10
 * http://opensource.org/licenses/osl-3.0.php
11
 *
12
 * PHP version 5
13
 *
14
 * @author    Tim Wagner <[email protected]>
15
 * @copyright 2019 TechDivision GmbH <[email protected]>
16
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
 * @link      https://github.com/appserver-io/appserver
18
 * @link      http://www.appserver.io
19
 */
20
21
namespace AppserverIo\Appserver\Ldap;
22
23
use AppserverIo\Storage\StackableStorage;
24
use AppserverIo\Psr\Application\ApplicationInterface;
25
use AppserverIo\Appserver\Core\Api\Node\ManagerNodeInterface;
26
use AppserverIo\Appserver\Core\Interfaces\ManagerFactoryInterface;
27
28
/**
29
 * The LDAP manager factory to create a new LDAP manager instance.
30
 *
31
 * @author    Tim Wagner <[email protected]>
32
 * @copyright 2019 TechDivision GmbH <[email protected]>
33
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
34
 * @link      https://github.com/appserver-io/appserver
35
 * @link      http://www.appserver.io
36
 */
37
class LdapManagerFactory implements ManagerFactoryInterface
38
{
39
40
    /**
41
     * The main method that creates new instances in a separate context.
42
     *
43
     * @param \AppserverIo\Psr\Application\ApplicationInterface         $application          The application instance to register the class loader with
44
     * @param \AppserverIo\Appserver\Core\Api\Node\ManagerNodeInterface $managerConfiguration The manager configuration
45
     *
46
     * @return void
47
     */
48
    public static function visit(ApplicationInterface $application, ManagerNodeInterface $managerConfiguration)
49
    {
50
51
        // initialize the stackable for the entities and the naming directory
52
        $data = new StackableStorage();
53
54
        // initialize the default settings for the stateful session beans
55
        $ldapManagerSettings = new LdapManagerSettings();
56
        $ldapManagerSettings->mergeWithParams($managerConfiguration->getParamsAsArray());
57
58
        // initialize the bean manager
59
        $ldapManager = new LdapManager();
60
        $ldapManager->injectData($data);
61
        $ldapManager->injectApplication($application);
62
        $ldapManager->injectManagerSettings($ldapManagerSettings);
63
        $ldapManager->injectManagerConfiguration($managerConfiguration);
64
65
        // create the naming context and add it the manager
66
        $contextFactory = $managerConfiguration->getContextFactory();
67
        $contextFactory::visit($ldapManager);
68
69
        // attach the instance
70
        $application->addManager($ldapManager, $managerConfiguration);
0 ignored issues
show
Bug introduced by
The method addManager() does not exist on AppserverIo\Psr\Application\ApplicationInterface. It seems like you code against a sub-type of AppserverIo\Psr\Application\ApplicationInterface such as AppserverIo\Appserver\Application\Application. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

70
        $application->/** @scrutinizer ignore-call */ 
71
                      addManager($ldapManager, $managerConfiguration);
Loading history...
71
    }
72
}
73