1 | <?php |
||
11 | class KeyFactory implements KeyFactoryInterface |
||
12 | { |
||
13 | const MAX_API_KEY_GENERATION_ATTEMPTS = 200; |
||
14 | |||
15 | /** |
||
16 | * @var ObjectManager |
||
17 | */ |
||
18 | private $om; |
||
19 | |||
20 | /** |
||
21 | * @var string |
||
22 | */ |
||
23 | private $modelName; |
||
24 | |||
25 | /** |
||
26 | * @var ClassMetadata |
||
27 | */ |
||
28 | private $metadata; |
||
29 | |||
30 | /** |
||
31 | * @var int |
||
32 | */ |
||
33 | private $keyLength; |
||
34 | |||
35 | /** |
||
36 | * Constructor. |
||
37 | * |
||
38 | * @param ObjectManager $om |
||
39 | * @param string $modelName |
||
40 | * @param ClassMetadata $metadata |
||
41 | * @param int $keyLength |
||
42 | */ |
||
43 | 14 | public function __construct(ObjectManager $om, $modelName, ClassMetadata $metadata, $keyLength = 200) |
|
50 | |||
51 | /** |
||
52 | * {@inheritdoc} |
||
53 | * |
||
54 | * @throws \RuntimeException If no unique key can be created. |
||
55 | */ |
||
56 | 8 | public function getKey() |
|
76 | |||
77 | /** |
||
78 | * Getter for the object manager. |
||
79 | * |
||
80 | * @return ObjectManager |
||
81 | */ |
||
82 | protected function getOm() |
||
86 | |||
87 | /** |
||
88 | * Getter for the model name. |
||
89 | * |
||
90 | * @return string |
||
91 | */ |
||
92 | protected function getModelName() |
||
96 | |||
97 | /** |
||
98 | * Getter for the api key property. |
||
99 | * |
||
100 | * @return ClassMetadata |
||
101 | */ |
||
102 | protected function getMetadata() |
||
106 | |||
107 | /** |
||
108 | * Getter for the key length. |
||
109 | * |
||
110 | * @return int |
||
111 | */ |
||
112 | protected function getKeyLength() |
||
116 | |||
117 | /** |
||
118 | * Generates the bare key. |
||
119 | * |
||
120 | * @return string |
||
121 | */ |
||
122 | 8 | protected function doGenerate() |
|
126 | } |
||
127 |