You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
See #2391. Adds "propertiesRespectOrder" option to AbstractResourceEntityRepresentation::displayValues(). Setting it to true changes default behavior to respect the order of properties passed in the "properties" option. The default behavior is to maintain the original property order, irrespective of the passed order. For example, this:
This won't work properly if properties contains terms that the resource has no values for: you'll get an entry for the "missing" terms in the final result when you shouldn't (despite its name, array_replace will introduce new keys in the result that aren't in the first arg).
It's possible to fix this with more array_ calls... one option that comes to mind would be doing another array_intersect_keys with the original $values passed second to drop out anything in we don't actually have a value for... but we may just want to swap this out with a foreach:
$result = [];
foreach ($options['properties'] as $term) {
if (isset($values[$term])) {
$result[$term] = $values[$term];
}
}
$values = $result;
I feel that propertiesRespectOrder is an awkward option name. It implies that the default behavior is somehow not respecting an order. Maybe a better option is originalOrder with the default set to true? That way the default behavior remains the same, and originalOrder=false respects the order passed in properties.
I'd want properties first in any option as this is something that only works with the properties option. propertiesOrdered or whatever if we want to shorten it, i'm fine with. The reverses, like propertiesOriginalOrder also fine, but also kind of long.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
See #2391. Adds "propertiesRespectOrder" option to
AbstractResourceEntityRepresentation::displayValues(). Setting it totruechanges default behavior to respect the order of properties passed in the "properties" option. The default behavior is to maintain the original property order, irrespective of the passed order. For example, this:will, in most cases, output "Title, Description, Subject" because that's the order defined on the resource itself. Whereas, this:
will output "Subject, Description, Title" because "propertiesRespectOrder" is
true, and that's the order passed in the "properties" option.