MT#56895 Deprecate 'api_embedded_forcearray' and 'api_links_forcearray' params

Both the parameters 'www_admin.api_embedded_forcearray' and
'www_admin.api_links_forcearray' were created long time ago
to have API backward compatible.
But the consistency of the returned values is a priority,
so we have to get rid of this option and keep the behavior
of the current default:
 * always return an array
 * always return lisk as an array

Change-Id: I75dccbf3b641a7e3c7f948c020cf2ebeb8a59065
mr12.1
Marco Capetta 2 years ago
parent f8fd17bb3e
commit a0b78678b8

@ -333,26 +333,23 @@ __PACKAGE__->log(Log::Log4perl::Catalyst->new($logger_config_file));
# configure Data::HAL depending on our config
{
if ($panel_config->{appearance}{api_embedded_forcearray} || $panel_config->{appearance}{api_links_forcearray}) {
require Data::HAL;
*{Data::HAL::forcearray_policy} = sub {
my ($self, $root, $property_type, $relation, $property) = @_;
my $embedded = $root->embedded ? $root->embedded->[0] : undef;
if ($embedded
&& ( ( $property_type eq 'links' && $panel_config->{appearance}{api_links_forcearray} )
|| ( $property_type eq 'embedded' && $panel_config->{appearance}{api_embedded_forcearray}) )
&& $relation =~/^ngcp:[a-z0-9]+$/
) {
return 1;
}
if (!$embedded
&& ( ( $property_type eq 'links' && $panel_config->{appearance}{api_links_forcearray} ) )
&& $relation =~/^ngcp:[a-z0-9]+$/
) {
return 1;
}
};
}
require Data::HAL;
*{Data::HAL::forcearray_policy} = sub {
my ($self, $root, $property_type, $relation, $property) = @_;
my $embedded = $root->embedded ? $root->embedded->[0] : undef;
if ($embedded
&& ( $property_type eq 'links' || $property_type eq 'embedded' )
&& $relation =~/^ngcp:[a-z0-9]+$/
) {
return 1;
}
if (!$embedded
&& ( $property_type eq 'links' )
&& $relation =~/^ngcp:[a-z0-9]+$/
) {
return 1;
}
};
}
after setup_finalize => sub {

Loading…
Cancel
Save