1 | <?php |
||
9 | class ApiKeyService implements ApiKeyServiceInterface |
||
10 | { |
||
11 | /** |
||
12 | * @var EntityManagerInterface |
||
13 | */ |
||
14 | private $em; |
||
15 | |||
16 | /** |
||
17 | * ApiKeyService constructor. |
||
18 | * @param EntityManagerInterface $em |
||
19 | * |
||
20 | * @Inject({"em"}) |
||
21 | */ |
||
22 | 10 | public function __construct(EntityManagerInterface $em) |
|
26 | |||
27 | /** |
||
28 | * Creates a new ApiKey with provided expiration date |
||
29 | * |
||
30 | * @param \DateTime $expirationDate |
||
31 | * @return ApiKey |
||
32 | */ |
||
33 | 2 | public function create(\DateTime $expirationDate = null) |
|
45 | |||
46 | /** |
||
47 | * Checks if provided key is a valid api key |
||
48 | * |
||
49 | * @param string $key |
||
50 | * @return bool |
||
51 | */ |
||
52 | 4 | public function check($key) |
|
62 | |||
63 | /** |
||
64 | * Disables provided api key |
||
65 | * |
||
66 | * @param string $key |
||
67 | * @return ApiKey |
||
68 | */ |
||
69 | 2 | public function disable($key) |
|
81 | |||
82 | /** |
||
83 | * Lists all existing appi keys |
||
84 | * |
||
85 | * @param bool $enabledOnly Tells if only enabled keys should be returned |
||
86 | * @return ApiKey[] |
||
87 | */ |
||
88 | 2 | public function listKeys($enabledOnly = false) |
|
93 | |||
94 | /** |
||
95 | * Tries to find one API key by its key string |
||
96 | * |
||
97 | * @param string $key |
||
98 | * @return ApiKey|null |
||
99 | */ |
||
100 | 6 | public function getByKey($key) |
|
106 | } |
||
107 |