File tree Expand file tree Collapse file tree 2 files changed +18
-3
lines changed Expand file tree Collapse file tree 2 files changed +18
-3
lines changed Original file line number Diff line number Diff line change 3
3
4
4
use Ubiquity \contents \validation \ValidationModelGenerator ;
5
5
use Ubiquity \annotations \AnnotationsEngineInterface ;
6
+ use Ubiquity \db \utils \DbTypes ;
6
7
7
8
/**
8
9
* Represents a data member in a model class.
@@ -155,6 +156,10 @@ public function getManyToOne() {
155
156
public function isPrimary () {
156
157
return $ this ->primary ;
157
158
}
159
+
160
+ public function isAutoinc (){
161
+ return $ this ->primary && DbTypes::isInt ( $ this ->getDbType () );
162
+ }
158
163
159
164
public function getGetter () {
160
165
$ result = "\n\tpublic function get " . \ucfirst ($ this ->name ) . "(){ \n" ;
Original file line number Diff line number Diff line change 4
4
use Ubiquity \utils \base \UArray ;
5
5
use Ubiquity \contents \transformation \TransformersManager ;
6
6
use Ubiquity \exceptions \TransformerException ;
7
+ use Ubiquity \db \utils \DbTypes ;
7
8
8
9
/**
9
10
* Parse model annotation for cache generation.
@@ -105,15 +106,24 @@ public function parse($modelClass) {
105
106
$ this ->fieldNames [$ propName ] = $ fieldName ;
106
107
$ this ->memberNames [$ fieldName ] = $ propName ;
107
108
$ nullable = Reflexion::isNullable ($ modelClass , $ propName );
109
+
108
110
$ serializable = Reflexion::isSerializable ($ modelClass , $ propName );
109
- if ($ nullable )
110
- $ this ->nullableMembers [] = $ propName ;
111
- if (! $ serializable )
111
+
112
+ if (! $ serializable ){
112
113
$ this ->notSerializableMembers [] = $ propName ;
114
+ }
113
115
$ type = Reflexion::getDbType ($ modelClass , $ propName );
114
116
if ($ type === false ) {
115
117
$ type = 'mixed ' ;
116
118
}
119
+
120
+ if (\array_search ($ fieldName , $ primaryKeys )!==false && DbTypes::isInt ($ type )){
121
+ $ nullable =true ;
122
+ }
123
+
124
+ if ($ nullable ){
125
+ $ this ->nullableMembers [] = $ propName ;
126
+ }
117
127
$ this ->fieldTypes [$ propName ] = $ type ;
118
128
$ accesseur = 'set ' . \ucfirst ($ propName );
119
129
if (! isset ($ this ->accessors [$ fieldName ]) && \method_exists ($ modelClass , $ accesseur )) {
You can’t perform that action at this time.
0 commit comments