Skip to content

Commit

Permalink
Issue #2298: pass the relevant ObjectType to ValueSet.
Browse files Browse the repository at this point in the history
The ObjectType gives information what the passed ObjectID means. Currently this is only relevant
for distinguishing between ITSMConfigItem and ITSMConfigItemVersion.
  • Loading branch information
bschmalhofer committed Jul 24, 2023
1 parent 5b57399 commit 064a153
Showing 1 changed file with 35 additions and 15 deletions.
50 changes: 35 additions & 15 deletions Kernel/System/DynamicField/Driver/Lens.pm
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,15 @@ sub ValueSet {
LensDynamicFieldConfig => $LensDFConfig,
);

my $ReferenceDFConfig = $Self->_GetReferenceDFConfig(
LensDynamicFieldConfig => $LensDFConfig,
);

return $Kernel::OM->Get('Kernel::System::DynamicField::Backend')->ValueSet(
%Param,
DynamicFieldConfig => $AttributeDFConfig,
ObjectID => $ReferencedObjectID,
ObjectType => $ReferenceDFConfig->{Config}->{ReferencedObjectType},
);
}

Expand Down Expand Up @@ -502,29 +507,21 @@ sub ValueLookup {
Methods that are used only internally.
=head2 _GetReferencedObjectID()
=head2 _GetReferenceDFConfig()
The ID of the referenced object.
A dynamic field configuration that can be used as a delegate.
=cut

sub _GetReferencedObjectID {
sub _GetReferenceDFConfig {
my ( $Self, %Param ) = @_;

my $LensDFConfig = $Param{LensDynamicFieldConfig};
my $ObjectID = $Param{ObjectID};

# Get the dynamic field for the referenced object
my $LensDFConfig = $Param{LensDynamicFieldConfig};
my $ReferenceDFID = $LensDFConfig->{Config}->{ReferenceDF};

my $ReferenceDFConfig = $Kernel::OM->Get('Kernel::System::DynamicField')->DynamicFieldGet(
return $Kernel::OM->Get('Kernel::System::DynamicField')->DynamicFieldGet(
ID => $ReferenceDFID,
);

return $Kernel::OM->Get('Kernel::System::DynamicField::Backend')->ValueGet(
DynamicFieldConfig => $ReferenceDFConfig,
ObjectID => $ObjectID,
);
}

=head2 _GetAttributeDFConfig()
Expand All @@ -536,13 +533,36 @@ A dynamic field configuration that can be used as a delegate.
sub _GetAttributeDFConfig {
my ( $Self, %Param ) = @_;

my $LensDFConfig = $Param{LensDynamicFieldConfig};

my $LensDFConfig = $Param{LensDynamicFieldConfig};
my $AttributeDFID = $LensDFConfig->{Config}->{AttributeDF};

return $Kernel::OM->Get('Kernel::System::DynamicField')->DynamicFieldGet(
ID => $AttributeDFID,
);
}

=head2 _GetReferencedObjectID()
The ID of the referenced object.
=cut

sub _GetReferencedObjectID {
my ( $Self, %Param ) = @_;

# extract params
my $LensDFConfig = $Param{LensDynamicFieldConfig};
my $ObjectID = $Param{ObjectID};

# Get the dynamic field config for the referenced object
my $ReferenceDFConfig = $Self->_GetReferenceDFConfig(
LensDynamicFieldConfig => $LensDFConfig,
);

return $Kernel::OM->Get('Kernel::System::DynamicField::Backend')->ValueGet(
DynamicFieldConfig => $ReferenceDFConfig,
ObjectID => $ObjectID,
);
}

1;

0 comments on commit 064a153

Please sign in to comment.