-
Notifications
You must be signed in to change notification settings - Fork 5
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
Add possibility to filter yaml keys #35
Add possibility to filter yaml keys #35
Conversation
Signed-off-by: Matthias Hamacher <m.hamacher@basecom.de>
We just now noticed that the fix:structure Command seems to be removing the filtered entries from the result file. I will have a look how we can fix that, but so long this should not be merged and released. |
src/Traits/ArrayTrait.php
Outdated
{ | ||
$result = []; | ||
|
||
foreach ($array as $key => $value) { | ||
if ($filter instanceof Filter && $filter->isKeyAllowed($key) === false) { | ||
continue; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we don't continue here but save the filtered keys into an additional array, we can remove them during loading and merging those two array together during saving/writing.
@boxblinkracer Would that be a feasible solution for the problem that the filtered keys are remove with the fix:structure
command?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hi
yes thats absolutely fine, a really good idea
so is that now already working, can i merge it like this @matthiashamacher ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No not right now. Wanted your input first so I haven't added it. Will add it later today and ping you so you can merge it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Finally found to time to finalize this pr. Was a little bit more complicated than I thought but I think its an ok solution @boxblinkracer Please have a look.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hi @matthiashamacher
awesome thank you, ill check it out later or this weekend :)
thanks for your work on that, means a lot
Signed-off-by: Matthias Hamacher <m.hamacher@basecom.de>
$filteredTranslations = []; | ||
|
||
foreach ($array as $key => $value) { | ||
if ($filter->isKeyAllowed($key, true) === true) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the only thing that i dont really get is the partial allowing?
why do we have that?
can you also explain that in a comment.
if i want to filter an array, i dont see a point where i would need partial filtering
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before I add the comment I explain it here, maybe there is a better way for the whole solution.
Background is that filtering during the first run through of flattening the array was no good solution in my opinion. During implementation there were too many changes needed to be done to save the filtered results. Therefore I moved it to this new function. As this runs after the array is flattened we have an array like this:
$array = [
'app.name' => 'test',
'app.description' => 'test',
];
If we now want to filter out description, we cannot filter by an exact match as the string would is app.description
therefore we need the partial match.
No description provided.