1 | <?php |
||
24 | class EntityDescriptor implements EntityDescriptorInterface |
||
25 | { |
||
26 | |||
27 | /** |
||
28 | * @var string Entity class name |
||
29 | */ |
||
30 | protected $entity; |
||
31 | |||
32 | /** |
||
33 | * @var string |
||
34 | */ |
||
35 | protected $tableName; |
||
36 | |||
37 | /** |
||
38 | * @var Inspector |
||
39 | */ |
||
40 | protected $inspector; |
||
41 | |||
42 | /** |
||
43 | * @var FieldsCollection |
||
44 | */ |
||
45 | protected $fields; |
||
46 | |||
47 | /** |
||
48 | * @var FieldDescriptor |
||
49 | */ |
||
50 | protected $primaryKey; |
||
51 | |||
52 | /** |
||
53 | * @var string |
||
54 | */ |
||
55 | protected $adapterAlias = '__undefined__'; |
||
56 | |||
57 | /** |
||
58 | * EntityDescriptor need an entity FQ class name. |
||
59 | * |
||
60 | * @param string $entity |
||
61 | */ |
||
62 | 10 | public function __construct($entity) |
|
67 | |||
68 | /** |
||
69 | * Gets entity table name |
||
70 | * |
||
71 | * @return string |
||
72 | */ |
||
73 | 6 | public function getTableName() |
|
80 | |||
81 | /** |
||
82 | * Returns entity fields |
||
83 | * |
||
84 | * @return FieldsCollection|FieldDescriptor[] |
||
85 | */ |
||
86 | 8 | public function getFields() |
|
97 | |||
98 | /** |
||
99 | * Returns the primary key field |
||
100 | * |
||
101 | * @return FieldDescriptor|null |
||
102 | */ |
||
103 | 6 | public function getPrimaryKey() |
|
115 | |||
116 | /** |
||
117 | * Determines the table name for current entity |
||
118 | * |
||
119 | * If there is an annotation @table present it will be used |
||
120 | * otherwise the name will be parsed by convention using the |
||
121 | * EntityDescriptor::parseTableName() method. |
||
122 | * |
||
123 | * @return string |
||
124 | */ |
||
125 | 4 | private function determineTableName() |
|
134 | |||
135 | /** |
||
136 | * Creates the descriptor if provided property has annotation @column |
||
137 | * |
||
138 | * @param $property |
||
139 | * |
||
140 | * @return self|$this|EntityDescriptor |
||
141 | */ |
||
142 | 6 | private function addDescriptor($property) |
|
154 | |||
155 | /** |
||
156 | * Parses the table name from the class name |
||
157 | * |
||
158 | * @param string $className |
||
159 | * |
||
160 | * @return string |
||
161 | */ |
||
162 | 10 | public static function parseTableName($className) |
|
177 | |||
178 | /** |
||
179 | * Returns the adapter alias name to use with this entity |
||
180 | * |
||
181 | * @return string |
||
182 | */ |
||
183 | 2 | public function getAdapterAlias() |
|
196 | |||
197 | /** |
||
198 | * Gets entity class name |
||
199 | * |
||
200 | * @return string |
||
201 | */ |
||
202 | public function className() |
||
206 | } |