File tree Expand file tree Collapse file tree 2 files changed +24
-2
lines changed Expand file tree Collapse file tree 2 files changed +24
-2
lines changed Original file line number Diff line number Diff line change 17
17
* This class is part of Ubiquity
18
18
*
19
19
* @author jcheron <[email protected] >
20
- * @version 1.0.2
20
+ * @version 1.0.3
21
21
* @category ubiquity.dev
22
22
*
23
23
*/
@@ -192,10 +192,29 @@ public function getSetter() {
192
192
return $ result ;
193
193
}
194
194
195
+ public function getAddInManyMember () {
196
+ if (\substr ($ this ->name , - 1 ) === 's ' ) {
197
+ $ name = \substr ($ this ->name , 0 , - 1 );
198
+ }
199
+ $ result = "\n\t public function add " . \ucfirst ($ name ) . '($ ' . $ name . "){ \n" ;
200
+ $ result .= "\t\t" . '$this-> ' . $ this ->name . '[]=$ ' . $ name . "; \n" ;
201
+ $ result .= "\t} \n" ;
202
+ return $ result ;
203
+ }
204
+
195
205
public function hasAnnotations () {
196
206
return \count ($ this ->annotations ) > 1 ;
197
207
}
198
208
209
+ public function isMany () {
210
+ foreach ($ this ->annotations as $ annot ) {
211
+ if (($ annot instanceof OneToManyAnnotation) || ($ annot instanceof ManyToManyAnnotation)) {
212
+ return true ;
213
+ }
214
+ }
215
+ return false ;
216
+ }
217
+
199
218
public function isNullable () {
200
219
if (isset ($ this ->annotations ['column ' ]))
201
220
return $ this ->annotations ['column ' ]->nullable ;
Original file line number Diff line number Diff line change 9
9
* This class is part of Ubiquity
10
10
*
11
11
* @author jcheron <[email protected] >
12
- * @version 1.0.4
12
+ * @version 1.0.5
13
13
* @category ubiquity.dev
14
14
*
15
15
*/
@@ -126,6 +126,9 @@ public function __toString() {
126
126
foreach ($ members as $ member ) {
127
127
$ result .= $ member ->getGetter ();
128
128
$ result .= $ member ->getSetter ();
129
+ if ($ member ->isMany ()) {
130
+ $ result .= $ member ->getAddInManyMember ();
131
+ }
129
132
}
130
133
$ result .= $ this ->getToString ();
131
134
$ result .= "\n} " ;
You can’t perform that action at this time.
0 commit comments