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
Adds a rule to slug #47
Conversation
Hey! Thank you very much for your contribution! I really like this addition, I will give it a closer look soon, but from what I've seen now it's looking really good. 👍 |
And I will also look into why Scrutinizer isn't building pull requests anymore :\ |
Hi @RickvdStaaij, i actually have a little problem with its usage right now :) I think most people will slug a field based on another one, say a To avoid using What i think should be the desired result would be to actually have no Here's an example for comprehension sake :) Actual result with $filter->value('slug')->slug('name');
$result = $filter->filter([
'foo' => 'bar',
]);
// $result = array(2) { ["foo"]=> string(3) "bar" ["slug"]=> NULL } Now the expected result should be : $filter->value('slug')->slug('name');
$result = $filter->filter([
'foo' => 'bar',
]);
// $result = array(2) { ["foo"]=> string(3) "bar" } <- no slug because, no slug provider "name" Any idea on how to acheive this ? Thanks ! |
Hi @RickvdStaaij, any thought on the question in my last comment ? Thanks ! |
@@ -230,6 +230,16 @@ public function replace($search, $replace) | |||
} | |||
|
|||
/** | |||
* Results that returns a value slugged | |||
* | |||
* @param type $fieldToSlugFrom |
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.
Should this be string
instead of type
?
@jhuet Sorry, I haven't had the time yet to check this out, but it's on the top of my todo list now, so I hope to get back to you soon. One thing that comes to mind, have you checkend https://github.com/particle-php/Filter/blob/master/src/Chain.php#L42? If you state that a rule is not empty, it shouldn't be ignored and turn up with the given value. |
Sorry it took me so long @jhuet, but I have (finally) looked into it in https://github.com/jhuet/Filter/pull/1. I introduced an I hope this is what you were looking for. If not let me know :) |
Make the slug non existant if null with setEmpty
No problem @RickvdStaaij, i'm glad to add new functionnalities to this library and see you're still around to help if needed :) Thanks ! |
]); | ||
|
||
$this->assertEquals(['test' => 'test'], $result); | ||
} |
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.
How about introducing an explaining variable here to improve clarity?
$data = [
'test' => 'test',
];
$this->assertSame($data, $this->filter->filter($data));
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.
Alright, you got it, i'm in a good mood today :)
Very nice @jhuet, thanks a lot! I'll merge and release a new version :) 👍 |
What?
Adds a rule to slug a field with its own value or from another field's.
Checklist
Linked issue
None.