[Rt-commit] rt branch, 4.2/expose-cf-to-cfvs, repushed
Kevin Falcone
falcone at bestpractical.com
Thu Dec 11 17:45:10 EST 2014
The branch 4.2/expose-cf-to-cfvs was deleted and repushed:
was 803ca7ff7d9b3b871f6f13f18fc3d05f544af86b
now 7e382cb9faf0b7954c4bb7d62ca01832d00eeabc
1: a84b429 = 1: a84b429 Keep track of which Custom Field object these Values belong to
2: 803ca7f ! 2: 7e382cb Pass down the CustomField object from the collection.
@@ -5,42 +5,61 @@
Given a RT::CustomFieldValue object you can now do the same
introspection that External Custom Fields can do on
RT::CustomFieldValues by looking at the actual CustomField object that
- was used to load the collection.
+ was used to load the collection. This is transparently returned by
+ ->CustomFieldObj as long as SetCustomFieldObj was called previously and
+ passed a CustomField which matches the one the database says this
+ CustomFieldValue belongs to.
diff --git a/lib/RT/CustomFieldValue.pm b/lib/RT/CustomFieldValue.pm
--- a/lib/RT/CustomFieldValue.pm
+++ b/lib/RT/CustomFieldValue.pm
@@
- $deps->Add( out => $self->CustomFieldObj );
- }
+ (In the database, CustomField will be stored as a int(11).)
-+=head2 SetCustomFieldObject
+
++=head2 SetCustomFieldObj
+
+Store the CustomField object which loaded this CustomFieldValue.
+Passed down from the CustomFieldValues collection in AddRecord.
+
-+=cut
++This object will be transparently returned from CustomFieldObj rather
++than loading from the database.
+
-+sub SetCustomFieldObject {
+ =cut
+
++sub SetCustomFieldObj {
+ my $self = shift;
+ return $self->{'custom_field'} = shift;
+}
+
+ =head2 CustomFieldObj
+
+-Returns the CustomField Object which has the id returned by CustomField
++If a CustomField object was stored using SetCustomFieldObj and it is
++the same CustomField stored in the CustomField column, then the stored
++CustomField object (likely passed down from CustomField->Values) will be returned.
+
++Otherwise returns the CustomField Object which has the id returned by CustomField
+
+ =cut
+
+ sub CustomFieldObj {
+ my $self = shift;
+
-+=head2 CustomFieldObject
++ return $self->{custom_field} if $self->{custom_field}
++ and $self->{custom_field}->id == $self->__Value('CustomField');
+
-+Returns the CustomField object used to load this CustomFieldValue.
-+Replies on the CustomFieldValues collection having a CustomFieldObject set.
-+
-+=cut
-+
-+sub CustomFieldObject {
-+ my $self = shift;
-+ return $self->{'custom_field'};
-+}
-+
+ my $CustomField = RT::CustomField->new($self->CurrentUser);
+ $CustomField->Load($self->__Value('CustomField'));
+ return($CustomField);
+@@
+ $deps->Add( out => $self->CustomFieldObj );
+ }
+-
RT::Base->_ImportOverlays();
+ 1;
diff --git a/lib/RT/CustomFieldValues.pm b/lib/RT/CustomFieldValues.pm
--- a/lib/RT/CustomFieldValues.pm
@@ -60,7 +79,7 @@
+ my $self = shift;
+ my $CFV = shift;
+
-+ $CFV->SetCustomFieldObject($self->CustomFieldObject);
++ $CFV->SetCustomFieldObj($self->CustomFieldObject);
+
+ push @{$self->{'items'}}, $CFV;
+ $self->{'rows'}++;
More information about the rt-commit
mailing list