Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH Add sorting by link type #167

Merged

Conversation

sabina-talipova
Copy link
Contributor

@sabina-talipova sabina-talipova commented Jan 11, 2024

Description

  • New class method that returns Menu labels;
  • Add sorting for main Link classes;

Parent issue

Copy link
Member

@GuySartorelli GuySartorelli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like unnecessary added complexity... why not just change the singular and plural names via private static $singular_name and private static $plural_name?

Edit: Nevermind, that would violate the acceptance criterion "The Link titles remain unchanged everywhere else." - so this is probably the right way to go about it.

src/Models/Link.php Outdated Show resolved Hide resolved
src/Models/FileLink.php Outdated Show resolved Hide resolved
src/Form/Traits/AllowedLinkClassesTrait.php Outdated Show resolved Hide resolved
@sabina-talipova sabina-talipova force-pushed the pulls/4/link-type-order branch 2 times, most recently from 713b256 to 8b2399b Compare January 11, 2024 20:25
@sabina-talipova sabina-talipova force-pushed the pulls/4/link-type-order branch from 8b2399b to 912816c Compare January 11, 2024 20:31
Copy link
Member

@GuySartorelli GuySartorelli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

linkfield with the link types in the new order with new labels
LGTM.

Comment on lines +101 to +103
uasort($typesList, function ($a, $b) {
return $a['priority'] - $b['priority'];
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
uasort($typesList, function ($a, $b) {
return $a['priority'] - $b['priority'];
});
uasort($typesList, fn ($a, $b) => $a['priority'] - $b['priority']);

I won't block merging the PR for this - but in the future we should use the short function syntax for this sort of thing, since we're just returning a value.
The long function syntax is only really valuable when we've got multiple lines of functionality or when the return statement is really long.

@GuySartorelli GuySartorelli merged commit fe72946 into silverstripe:4 Jan 11, 2024
10 checks passed
@GuySartorelli GuySartorelli deleted the pulls/4/link-type-order branch January 11, 2024 21:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants