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 1717 * This class is part of Ubiquity
1818 *
1919 * @author jcheron <[email protected] > 20- * @version 1.0.2
20+ * @version 1.0.3
2121 * @category ubiquity.dev
2222 *
2323 */
@@ -192,10 +192,29 @@ public function getSetter() {
192192 return $ result ;
193193 }
194194
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+
195205 public function hasAnnotations () {
196206 return \count ($ this ->annotations ) > 1 ;
197207 }
198208
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+
199218 public function isNullable () {
200219 if (isset ($ this ->annotations ['column ' ]))
201220 return $ this ->annotations ['column ' ]->nullable ;
Original file line number Diff line number Diff line change 99 * This class is part of Ubiquity
1010 *
1111 * @author jcheron <[email protected] > 12- * @version 1.0.4
12+ * @version 1.0.5
1313 * @category ubiquity.dev
1414 *
1515 */
@@ -126,6 +126,9 @@ public function __toString() {
126126 foreach ($ members as $ member ) {
127127 $ result .= $ member ->getGetter ();
128128 $ result .= $ member ->getSetter ();
129+ if ($ member ->isMany ()) {
130+ $ result .= $ member ->getAddInManyMember ();
131+ }
129132 }
130133 $ result .= $ this ->getToString ();
131134 $ result .= "\n} " ;
You can’t perform that action at this time.
0 commit comments