Skip to content

Commit

Permalink
Merge pull request #2859 from RotherOSS/issue-#2850-has_behavior
Browse files Browse the repository at this point in the history
Issue #2850 has behavior
  • Loading branch information
bschmalhofer authored Jan 22, 2024
2 parents 0c0d3d8 + 81402d4 commit 9da065f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
6 changes: 4 additions & 2 deletions Kernel/System/DynamicField/Backend.pm
Original file line number Diff line number Diff line change
Expand Up @@ -2272,7 +2272,7 @@ sub ValueLookup {
checks whether the dynamic field has a specified behavior
my $Success = $BackendObject->HasBehavior(
my $HasBehavior = $BackendObject->HasBehavior(
DynamicFieldConfig => $DynamicFieldConfig, # complete config of the DynamicField
Behavior => 'Some Behavior', # 'IsACLReducible' to be reduded by ACLs
# and updatable via AJAX
Expand All @@ -2298,7 +2298,9 @@ checks whether the dynamic field has a specified behavior
returns:
$Success = 1; # or undefined (if the dynamic field does not have that behavior)
$HasBehavior = 1; # if the dynamic field has that behavior
$HasBehavior = undef; # if the dynamic field does not have that behavior
$HasBehavior = undef; # if some kind of unexpected input or declaration is encountered
=cut

Expand Down
5 changes: 4 additions & 1 deletion Kernel/System/DynamicField/Driver/Base.pm
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,11 @@ sub HasBehavior {
# return fail if Behaviors hash does not exists
return unless IsHashRefWithData( $Self->{Behaviors} );

# avoid hash lookup with an undefined value
return unless defined $Param{Behavior};

# return success if the dynamic field has the expected behavior
return IsPositiveInteger( $Self->{Behaviors}->{ $Param{Behavior} } );
return $Self->{Behaviors}->{ $Param{Behavior} } ? 1 : undef;
}

sub SearchFieldPreferences {
Expand Down
2 changes: 1 addition & 1 deletion Kernel/System/DynamicField/Driver/Lens.pm
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ sub HasBehavior {
}

# return success if the dynamic field has the expected behavior
return IsPositiveInteger( $Self->{Behaviors}->{ $Param{Behavior} } );
return SUPER::HasBehavior( Behavior => $Param{Behavior} );
}

sub PossibleValuesGet {
Expand Down
4 changes: 2 additions & 2 deletions Kernel/System/VariableCheck.pm
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,9 @@ sub IsArrayRefWithData {

=head2 IsHashRefWithData()
test supplied data to determine if it is a hash reference and contains at least one key/value pair
tests supplied data to determine if it is a hash reference and contains at least one key/value pair.
returns 1 if data matches criteria or undef otherwise
Returns 1 if data matches criteria or undef otherwise
my $Result = IsHashRefWithData(
{ # data to be tested
Expand Down

0 comments on commit 9da065f

Please sign in to comment.