Skip to content

Conversation

@Monviech
Copy link
Member

@Monviech Monviech commented Dec 8, 2025

Uses two methods (toggle log and move rule) that I generalized into base helper methods in this PR: #9492

image

@Monviech Monviech self-assigned this Dec 8, 2025
@Monviech Monviech added the feature Adding new functionality label Dec 8, 2025
@Monviech Monviech changed the title nat: Refactor network prefix translation (NPT) view nat/npt: Refactor network prefix translation view Dec 8, 2025
@Monviech Monviech added cleanup Low impact changes and removed feature Adding new functionality labels Dec 8, 2025
$filter_funct = function ($record) use ($category) {
return empty($category) || array_intersect(explode(',', $record->categories), $category);
/* categories are indexed by name in the record, but offered as uuid in the selector */
$catids = !empty((string)$record->categories) ? explode(',', (string)$record->categories) : [];
Copy link
Member

Choose a reason for hiding this comment

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

string? :D explode? :D

getValues()

return empty($category) || array_intersect(explode(',', $record->categories), $category);
/* categories are indexed by name in the record, but offered as uuid in the selector */
$catids = !empty((string)$record->categories) ? explode(',', (string)$record->categories) : [];
return empty($category) || array_intersect($catids, $category);
Copy link
Member

Choose a reason for hiding this comment

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

if you cast to array please use count()

Copy link
Member Author

Choose a reason for hiding this comment

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

Can I fix this in a separate PR, because the same pattern is used in 3 or 4 other controllers.

Copy link
Member

Choose a reason for hiding this comment

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

okay

foreach ($results['rows'] as &$record) {
/* offer list of colors to be used by the frontend */
$record['category_colors'] = $this->getCategoryColors(
!empty($record['categories']) ? explode(',', $record['categories']) : []
Copy link
Member

Choose a reason for hiding this comment

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

why are we getting array keys here instead of objects? these constructs handling multi value conversions are not good as they bloat the controller code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cleanup Low impact changes

Development

Successfully merging this pull request may close these issues.

3 participants