@@ -78,6 +78,10 @@ public function getTransactionTypes() {
78
78
$ types [] = PhabricatorTransactions::TYPE_SUBSCRIBERS ;
79
79
}
80
80
81
+ if ($ this ->object instanceof PhabricatorCustomFieldInterface) {
82
+ $ types [] = PhabricatorTransactions::TYPE_CUSTOMFIELD ;
83
+ }
84
+
81
85
return $ types ;
82
86
}
83
87
@@ -121,6 +125,9 @@ private function getTransactionOldValue(
121
125
$ old_edges = $ old_edges [$ edge_src ][$ edge_type ];
122
126
}
123
127
return $ old_edges ;
128
+ case PhabricatorTransactions::TYPE_CUSTOMFIELD :
129
+ $ field = $ this ->getCustomFieldForTransaction ($ object , $ xaction );
130
+ return $ field ->getOldValueForApplicationTransactions ();
124
131
default :
125
132
return $ this ->getCustomTransactionOldValue ($ object , $ xaction );
126
133
}
@@ -137,6 +144,9 @@ private function getTransactionNewValue(
137
144
return $ xaction ->getNewValue ();
138
145
case PhabricatorTransactions::TYPE_EDGE :
139
146
return $ this ->getEdgeTransactionNewValue ($ xaction );
147
+ case PhabricatorTransactions::TYPE_CUSTOMFIELD :
148
+ $ field = $ this ->getCustomFieldForTransaction ($ object , $ xaction );
149
+ return $ field ->getNewValueForApplicationTransactions ();
140
150
default :
141
151
return $ this ->getCustomTransactionNewValue ($ object , $ xaction );
142
152
}
@@ -161,6 +171,9 @@ protected function transactionHasEffect(
161
171
switch ($ xaction ->getTransactionType ()) {
162
172
case PhabricatorTransactions::TYPE_COMMENT :
163
173
return $ xaction ->hasComment ();
174
+ case PhabricatorTransactions::TYPE_CUSTOMFIELD :
175
+ $ field = $ this ->getCustomFieldForTransaction ($ object , $ xaction );
176
+ return $ field ->getApplicationTransactionHasEffect ($ xaction );
164
177
}
165
178
166
179
return ($ xaction ->getOldValue () !== $ xaction ->getNewValue ());
@@ -176,6 +189,9 @@ private function applyInternalEffects(
176
189
case PhabricatorTransactions::TYPE_EDIT_POLICY :
177
190
$ object ->setEditPolicy ($ xaction ->getNewValue ());
178
191
break ;
192
+ case PhabricatorTransactions::TYPE_CUSTOMFIELD :
193
+ $ field = $ this ->getCustomFieldForTransaction ($ object , $ xaction );
194
+ return $ field ->applyApplicationTransactionInternalEffects ($ xaction );
179
195
}
180
196
return $ this ->applyCustomInternalTransaction ($ object , $ xaction );
181
197
}
@@ -240,6 +256,9 @@ private function applyExternalEffects(
240
256
241
257
$ editor ->save ();
242
258
break ;
259
+ case PhabricatorTransactions::TYPE_CUSTOMFIELD :
260
+ $ field = $ this ->getCustomFieldForTransaction ($ object , $ xaction );
261
+ return $ field ->applyApplicationTransactionExternalEffects ($ xaction );
243
262
}
244
263
245
264
return $ this ->applyCustomExternalTransaction ($ object , $ xaction );
@@ -1244,4 +1263,41 @@ protected function supportsSearch() {
1244
1263
return false ;
1245
1264
}
1246
1265
1266
+
1267
+ /* -( Custom Fields )------------------------------------------------------- */
1268
+
1269
+
1270
+ /**
1271
+ * @task customfield
1272
+ */
1273
+ private function getCustomFieldForTransaction (
1274
+ PhabricatorLiskDAO $ object ,
1275
+ PhabricatorApplicationTransaction $ xaction ) {
1276
+
1277
+ $ field_key = $ xaction ->getMetadataValue ('customfield:key ' );
1278
+ if (!$ field_key ) {
1279
+ throw new Exception (
1280
+ "Custom field transaction has no 'customfield:key'! " );
1281
+ }
1282
+
1283
+ $ field = PhabricatorCustomField::getObjectField (
1284
+ $ object ,
1285
+ PhabricatorCustomField::ROLE_APPLICATIONTRANSACTIONS ,
1286
+ $ field_key );
1287
+
1288
+ if (!$ field ) {
1289
+ throw new Exception (
1290
+ "Custom field transaction has invalid 'customfield:key'; field " .
1291
+ "' {$ field_key }' is disabled or does not exist. " );
1292
+ }
1293
+
1294
+ if (!$ field ->shouldAppearInApplicationTransactions ()) {
1295
+ throw new Exception (
1296
+ "Custom field transaction ' {$ field_key }' does not implement " .
1297
+ "integration for ApplicationTransactions. " );
1298
+ }
1299
+
1300
+ return $ field ;
1301
+ }
1302
+
1247
1303
}
0 commit comments