1 | <?php |
||
19 | class ConnectorFactory implements LoggerAwareInterface |
||
20 | { |
||
21 | use LoggerAwareTrait; |
||
22 | |||
23 | const PLATFORM_PATH = 'WebservicesNl\\Platform\\%1$s\\PlatformConfig'; |
||
24 | const PROTOCOL_PATH = 'WebservicesNl\\Protocol\\%1$s\\Client\\%1$sFactory'; |
||
25 | const ADAPTER_PATH = 'WebservicesNl\\Connector\\ProtocolAdapter\\%1$sAdapter'; |
||
26 | |||
27 | /** |
||
28 | * Generic user settings (eg credentials). |
||
29 | * |
||
30 | * @var array |
||
31 | */ |
||
32 | protected $userSettings; |
||
33 | |||
34 | /** |
||
35 | * ConnectorFactory constructor. |
||
36 | * |
||
37 | * @param array $settings |
||
38 | */ |
||
39 | public function __construct(array $settings = []) |
||
43 | |||
44 | /** |
||
45 | * @param array $settings |
||
46 | * |
||
47 | * @return static |
||
48 | */ |
||
49 | public static function build(array $settings = []) |
||
53 | |||
54 | /** |
||
55 | * Creates an adapter for given platform and client. |
||
56 | * Wrap the client inside a platform adapter. |
||
57 | * |
||
58 | * @param ClientInterface $client |
||
59 | * |
||
60 | * @return AdapterInterface |
||
61 | * @throws InputException |
||
62 | */ |
||
63 | private function buildAdapter(ClientInterface $client) |
||
71 | |||
72 | /** |
||
73 | * Creates an connection for a given platform. |
||
74 | * |
||
75 | * @param string $protocolName type of connection (SOAP, REST etc) |
||
76 | * @param string $platformName |
||
77 | * |
||
78 | * @return ConnectorInterface |
||
79 | * @throws InputException |
||
80 | */ |
||
81 | public function create($protocolName, $platformName) |
||
96 | |||
97 | /** |
||
98 | * Build the connector with given client and platform config. |
||
99 | * |
||
100 | * @param ClientInterface $client |
||
101 | * @param PlatformConfigInterface $config |
||
102 | * |
||
103 | * @return ConnectorInterface |
||
104 | * @throws \WebservicesNl\Common\Exception\Client\InputException |
||
105 | */ |
||
106 | private function buildConnector(ClientInterface $client, PlatformConfigInterface $config) |
||
113 | |||
114 | /** |
||
115 | * @return LoggerInterface |
||
116 | */ |
||
117 | public function getLogger() |
||
121 | |||
122 | /** |
||
123 | * Tries to find the factory for given protocol, to configure and create the ClientInterface. |
||
124 | * |
||
125 | * @param string $protocolName name of the protocol |
||
126 | * @param PlatformConfigInterface $config platform config object |
||
127 | * |
||
128 | * @return ClientFactoryInterface |
||
129 | * @throws InputException |
||
130 | */ |
||
131 | private function createProtocolFactory($protocolName, PlatformConfigInterface $config) |
||
141 | |||
142 | /** |
||
143 | * Build a platform config with given settings. |
||
144 | * |
||
145 | * @param string $platformName |
||
146 | * |
||
147 | * @return PlatformConfigInterface |
||
148 | * @throws InputException |
||
149 | */ |
||
150 | private function createPlatformConfig($platformName) |
||
164 | } |
||
165 |