1
|
|
|
<?php |
2
|
|
|
namespace OAuth; |
3
|
|
|
|
4
|
|
|
use Del\Common\Container\RegistrationInterface; |
5
|
|
|
use Doctrine\ORM\EntityManager; |
6
|
|
|
use OAuth\Repository\AccessTokenRepository; |
7
|
|
|
use Pimple\Container; |
8
|
|
|
|
9
|
|
|
class OAuthPackage implements RegistrationInterface |
10
|
|
|
{ |
11
|
|
|
/** |
12
|
|
|
* @param Container $c |
13
|
|
|
*/ |
14
|
|
|
public function addToContainer(Container $c) |
15
|
|
|
{ |
16
|
|
|
// AccessToken |
17
|
|
|
$function = function ($c) { |
18
|
|
|
/** @var EntityManager $entityManager */ |
19
|
|
|
$entityManager = $c['doctrine.entity_manager']; |
20
|
|
|
$repository = $entityManager->getRepository('OAuth\AccessToken'); |
21
|
|
|
return $repository; |
22
|
|
|
}; |
23
|
|
|
$c['repository.AccessToken'] = $c->factory($function); |
24
|
|
|
|
25
|
|
|
// AuthCode |
26
|
|
|
$function = function ($c) { |
27
|
|
|
/** @var EntityManager $entityManager */ |
28
|
|
|
$entityManager = $c['doctrine.entity_manager']; |
29
|
|
|
$repository = $entityManager->getRepository('OAuth\AuthCode'); |
30
|
|
|
return $repository; |
31
|
|
|
}; |
32
|
|
|
$c['repository.AuthCode'] = $c->factory($function); |
33
|
|
|
|
34
|
|
|
// Client |
35
|
|
|
$function = function ($c) { |
36
|
|
|
/** @var EntityManager $entityManager */ |
37
|
|
|
$entityManager = $c['doctrine.entity_manager']; |
38
|
|
|
$repository = $entityManager->getRepository('OAuth\Client'); |
39
|
|
|
return $repository; |
40
|
|
|
}; |
41
|
|
|
$c['repository.Client'] = $c->factory($function); |
42
|
|
|
|
43
|
|
|
// RefreshToken |
44
|
|
|
$function = function ($c) { |
45
|
|
|
/** @var EntityManager $entityManager */ |
46
|
|
|
$entityManager = $c['doctrine.entity_manager']; |
47
|
|
|
$repository = $entityManager->getRepository('OAuth\RefreshToken'); |
48
|
|
|
return $repository; |
49
|
|
|
}; |
50
|
|
|
$c['repository.RefreshToken'] = $c->factory($function); |
51
|
|
|
|
52
|
|
|
// Scope |
53
|
|
|
$function = function ($c) { |
54
|
|
|
/** @var EntityManager $entityManager */ |
55
|
|
|
$entityManager = $c['doctrine.entity_manager']; |
56
|
|
|
$repository = $entityManager->getRepository('OAuth\Scope'); |
57
|
|
|
return $repository; |
58
|
|
|
}; |
59
|
|
|
$c['repository.Scope'] = $c->factory($function); |
60
|
|
|
|
61
|
|
|
// User |
62
|
|
|
$function = function ($c) { |
63
|
|
|
/** @var EntityManager $entityManager */ |
64
|
|
|
$entityManager = $c['doctrine.entity_manager']; |
65
|
|
|
$repository = $entityManager->getRepository('OAuth\User'); |
66
|
|
|
return $repository; |
67
|
|
|
}; |
68
|
|
|
$c['repository.User'] = $c->factory($function); |
69
|
|
|
|
70
|
|
|
|
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
public function getEntityPath() |
74
|
|
|
{ |
75
|
|
|
return 'src/Entity/OAuth'; |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
public function hasEntityPath() |
79
|
|
|
{ |
80
|
|
|
return true; |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
} |