File tree Expand file tree Collapse file tree 5 files changed +24
-2
lines changed Expand file tree Collapse file tree 5 files changed +24
-2
lines changed Original file line number Diff line number Diff line change @@ -83,6 +83,17 @@ Example:
83
83
parent: false # No parent
84
84
` ` `
85
85
86
+ # # Forcing a class to be abstract
87
+
88
+ Force a class to be `abstract` (or to be not).
89
+
90
+ Example :
91
+
92
+ ` ` ` yaml
93
+ Person:
94
+ abstract: true
95
+ ` ` `
96
+
86
97
# # Author PHPDoc
87
98
88
99
Add a `@author` PHPDoc annotation to class' DocBlock.
Original file line number Diff line number Diff line change @@ -33,7 +33,7 @@ public function generateClassAnnotations($className)
33
33
if (isset ($ this ->config ['types ' ][$ class ['resource ' ]->localName ()]['doctrine ' ]['inheritanceMapping ' ])) {
34
34
$ inheritanceMapping = $ this ->config ['types ' ][$ class ['resource ' ]->localName ()]['doctrine ' ]['inheritanceMapping ' ];
35
35
} else {
36
- $ inheritanceMapping = $ class ['hasChild ' ] ? '@ORM\MappedSuperclass ' : '@ORM\Entity ' ;
36
+ $ inheritanceMapping = $ class ['abstract ' ] ? '@ORM\MappedSuperclass ' : '@ORM\Entity ' ;
37
37
}
38
38
39
39
return [
Original file line number Diff line number Diff line change @@ -111,6 +111,7 @@ public function generate($config)
111
111
'uses ' => [],
112
112
'hasConstructor ' => false ,
113
113
'hasChild ' => false ,
114
+ 'abstract ' => false ,
114
115
];
115
116
116
117
$ typesDefined = !empty ($ config ['types ' ]);
@@ -286,6 +287,15 @@ public function generate($config)
286
287
}
287
288
}
288
289
290
+ // Third pass
291
+ foreach ($ classes as &$ class ) {
292
+ if (isset ($ config ['types ' ][$ class ['name ' ]]['abstract ' ]) && null !== $ config ['types ' ][$ class ['name ' ]]['abstract ' ]) {
293
+ $ class ['abstract ' ] = $ config ['types ' ][$ class ['name ' ]]['abstract ' ];
294
+ } else {
295
+ $ class ['abstract ' ] = $ class ['hasChild ' ];
296
+ }
297
+ }
298
+
289
299
// Generate ID
290
300
if ($ config ['generateId ' ]) {
291
301
foreach ($ classes as &$ class ) {
Original file line number Diff line number Diff line change @@ -74,6 +74,7 @@ public function getConfigTreeBuilder()
74
74
->useAttributeAsKey ('id ' )
75
75
->prototype ('array ' )
76
76
->children ()
77
+ ->booleanNode ('abstract ' )->defaultNull ()->info ('Is the class abstract? (null to guess) ' )->end ()
77
78
->arrayNode ('namespaces ' )
78
79
->addDefaultsIfNotSet ()
79
80
->info ('Type namespaces ' )
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ use {{ use }};
19
19
* {{ annotation }}
20
20
{% endfor %}
21
21
*/
22
- {% if class . hasChild % }abstract {% endif % }class {{ class . name }}{% if class . parent % } extends {{ class . parent }}{% endif % }{% if class . interfaceName % } implements {{ class . interfaceName }}{% endif % }
22
+ {% if class . abstract % }abstract {% endif % }class {{ class . name }}{% if class . parent % } extends {{ class . parent }}{% endif % }{% if class . interfaceName % } implements {{ class . interfaceName }}{% endif % }
23
23
{
24
24
{% for constant in class . constants % }
25
25
/**
You can’t perform that action at this time.
0 commit comments