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

Add $path parameter to Hash::filter() #14951

Closed
1 of 3 tasks
andrii-pukhalevych opened this issue Sep 1, 2020 · 5 comments
Closed
1 of 3 tasks

Add $path parameter to Hash::filter() #14951

andrii-pukhalevych opened this issue Sep 1, 2020 · 5 comments

Comments

@andrii-pukhalevych
Copy link
Contributor

andrii-pukhalevych commented Sep 1, 2020

This is a (multiple allowed):

  • bug

  • enhancement

  • feature-discussion (RFC)

  • CakePHP Version: 3.9, 4

Add 3r parameter $path parameter to Hash::filter() to allow filter by deep values (or maybe create new function).
Currently it filters only by top level values:
public static function filter(array $data, $callback = ['self', '_filter'])

@markstory markstory added this to the 4.2.0 milestone Sep 2, 2020
@markstory
Copy link
Member

Currently it filters only by top level values:

Are you sure about that? There are tests covering that Hash::filter() recurses into all array values as well. How would the proposed path parameter work? Would only those paths be filtered?

@andrii-pukhalevych
Copy link
Contributor Author

I just want to filter root array by some filed, specified in path without using array_filter + callback:
Hash::filter($data, '{*}.is_enabled')

@markstory
Copy link
Member

That sounds like another method. Perhaps something like Hash::filterBy()?

@T0mats0
Copy link

T0mats0 commented Oct 17, 2020

How would a filterBy function be different than extract?

@markstory markstory modified the milestones: 4.2.0, 4.3.0 Dec 21, 2020
@github-actions
Copy link

github-actions bot commented May 9, 2021

This issue is stale because it has been open for 120 days with no activity. Remove the stale label or comment or this will be closed in 15 days

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

No branches or pull requests

4 participants