1 | <?php |
||
10 | class OAuthPackage implements RegistrationInterface |
||
11 | { |
||
12 | /** |
||
13 | * @param Container $c |
||
14 | */ |
||
15 | public function addToContainer(Container $c) |
||
16 | { |
||
17 | // AccessToken |
||
18 | 1 | $function = function ($c) { |
|
19 | /** @var EntityManager $entityManager */ |
||
20 | 1 | $entityManager = $c['doctrine.entity_manager']; |
|
21 | 1 | $repository = $entityManager->getRepository('OAuth\AccessToken'); |
|
22 | 1 | return $repository; |
|
23 | 1 | }; |
|
24 | 1 | $c['repository.AccessToken'] = $c->factory($function); |
|
25 | |||
26 | // AuthCode |
||
27 | 1 | $function = function ($c) { |
|
28 | /** @var EntityManager $entityManager */ |
||
29 | 1 | $entityManager = $c['doctrine.entity_manager']; |
|
30 | 1 | $repository = $entityManager->getRepository('OAuth\AuthCode'); |
|
31 | return $repository; |
||
32 | 1 | }; |
|
33 | 1 | $c['repository.AuthCode'] = $c->factory($function); |
|
34 | |||
35 | // Client |
||
36 | 1 | $function = function ($c) { |
|
37 | /** @var EntityManager $entityManager */ |
||
38 | $entityManager = $c['doctrine.entity_manager']; |
||
39 | $repository = $entityManager->getRepository('OAuth\Client'); |
||
40 | return $repository; |
||
41 | 1 | }; |
|
42 | 1 | $c['repository.Client'] = $c->factory($function); |
|
43 | |||
44 | 1 | $function = function ($c) { |
|
45 | $repository = $c['repository.Client']; |
||
46 | $svc = new ClientService($repository); |
||
47 | return $svc; |
||
48 | 1 | }; |
|
49 | 1 | $c['oauth.service.client'] = $c->factory($function); |
|
50 | |||
51 | // RefreshToken |
||
52 | 1 | $function = function ($c) { |
|
53 | /** @var EntityManager $entityManager */ |
||
54 | $entityManager = $c['doctrine.entity_manager']; |
||
55 | $repository = $entityManager->getRepository('OAuth\RefreshToken'); |
||
56 | return $repository; |
||
57 | 1 | }; |
|
58 | 1 | $c['repository.RefreshToken'] = $c->factory($function); |
|
59 | |||
60 | // Scope |
||
61 | 1 | $function = function ($c) { |
|
62 | /** @var EntityManager $entityManager */ |
||
63 | $entityManager = $c['doctrine.entity_manager']; |
||
64 | $repository = $entityManager->getRepository('OAuth\Scope'); |
||
65 | return $repository; |
||
66 | 1 | }; |
|
67 | 1 | $c['repository.Scope'] = $c->factory($function); |
|
68 | |||
69 | // User |
||
70 | 1 | $function = function ($c) { |
|
71 | /** @var EntityManager $entityManager */ |
||
72 | $entityManager = $c['doctrine.entity_manager']; |
||
73 | $repository = $entityManager->getRepository('OAuth\User'); |
||
74 | return $repository; |
||
75 | 1 | }; |
|
76 | 1 | $c['repository.User'] = $c->factory($function); |
|
77 | 1 | } |
|
78 | |||
79 | 1 | public function getEntityPath() |
|
83 | |||
84 | 1 | public function hasEntityPath() |
|
88 | |||
89 | } |