|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* YAWIK |
|
4
|
|
|
* |
|
5
|
|
|
* @filesource |
|
6
|
|
|
* @copyright (c) 2013 - 2016 Cross Solution (http://cross-solution.de) |
|
7
|
|
|
* @license MIT |
|
8
|
|
|
*/ |
|
9
|
|
|
|
|
10
|
|
|
namespace Auth\Factory\Adapter; |
|
11
|
|
|
|
|
12
|
|
|
use Interop\Container\ContainerInterface; |
|
13
|
|
|
use Zend\ServiceManager\FactoryInterface; |
|
14
|
|
|
use Zend\ServiceManager\ServiceLocatorInterface; |
|
15
|
|
|
use Auth\Adapter\HybridAuth as HybridAuthAdapter; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* HybridAuth authentication adapter factory |
|
19
|
|
|
*/ |
|
20
|
|
|
class HybridAuthAdapterFactory implements FactoryInterface |
|
21
|
|
|
{ |
|
22
|
|
|
/** |
|
23
|
|
|
* Create a HybridAuthAdapter adapter |
|
24
|
|
|
* |
|
25
|
|
|
* authentication with HybridAuth |
|
26
|
|
|
* |
|
27
|
|
|
* @param ContainerInterface $container |
|
28
|
|
|
* @param string $requestedName |
|
29
|
|
|
* @param null|array $options |
|
30
|
|
|
* |
|
31
|
|
|
* @return HybridAuthAdapter |
|
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
|
|
|
$adapter = new HybridAuthAdapter(); |
|
40
|
|
|
$adapter->setHybridAuth($container->get('HybridAuth')); |
|
41
|
|
|
$adapter->setRepository($container->get('repositories')->get('Auth/User')); |
|
42
|
|
|
$adapter->setSocialProfilePlugin($container->get('ControllerPluginManager')->get('Auth/SocialProfiles')); |
|
43
|
|
|
return $adapter; |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* @param ServiceLocatorInterface $serviceLocator |
|
48
|
|
|
* @return \Auth\Adapter\HybridAuth |
|
49
|
|
|
* @see \Zend\ServiceManager\FactoryInterface::createService() |
|
50
|
|
|
*/ |
|
51
|
|
|
public function createService(ServiceLocatorInterface $serviceLocator) |
|
52
|
|
|
{ |
|
53
|
|
|
return $this($serviceLocator, HybridAuthAdapter::class); |
|
54
|
|
|
} |
|
55
|
|
|
} |
|
56
|
|
|
|