Add hooks to modify ArrayTransformer, TextTransformer and set transform Constraints#30
Add hooks to modify ArrayTransformer, TextTransformer and set transform Constraints#30perrelet wants to merge 7 commits intomarcbelletre:masterfrom
Conversation
|
Hi @perrelet, Thank you for this PR! Also I would suggest changing the names of the filters for two reasons:
I would be happy to merge this PR then ;) |
|
I have changed the hook signatures to lowercase and used the Here's a couple of examples of how these can be used: 1. Limit the number of instances generated for a recurring event with no end date add_filter('acf_rrule/recurr/array_transformer', function (Recurr\Transformer\ArrayTransformer $transformer) {
$config = new Recurr\Transformer\ArrayTransformerConfig();
$config->setVirtualLimit(200);
$transformer->setConfig($config);
});2. Only generate instances between a date range add_filter('acf_rrule/recurr/constraint', function ($constraint) {
$from = new DateTime();
$to = (new DateTime())->modify('+1 month');
return new Recurr\Transformer\Constraint\BetweenConstraint($from, $to, true);
});Let me know if you need any more information or changes 👍 |
|
Hi @marcbelletre, This PR remains of immense benefit to our implementations of Would you be able to review this? Many thanks 🙏 |
|
Hello there! I'm really sorry I abandoned this project and I appreciate your patience! I stopped working as a freelancer last year and got a new position where I don't use Wordpress at all. I don't use this plugin anymore and I honestly don't have time to continue maintaining it. I would be happy to transfer the ownership of the repository to you or anyone who would like to take over the project maintenance, as well as the WordPress SVN access, so you guys can continue using it :) Don't hesitate to send me an email if you'd like to get in touch. Cheers! |
It would be helpful if we could modify the
Recurr\Transformer\ArrayTransformerandRecurr\Transformer\TextTransformerobjects. Further,ArrayTransformer::transformalso accepts an optional second argument to set a constraint by passing one of:Recurr\Transformer\Constraint\AfterConstraintRecurr\Transformer\Constraint\BeforeConstraintRecurr\Transformer\Constraint\BetweenConstraintWe propose adding the following filters to expose these features:
apply_filters('ACF/RRule/ArrayTransformer', $transformer);apply_filters('ACF/RRule/TextTransformer', $textTransformer);$constraint = apply_filters('ACF/RRule/Constraint', null);We need to add an additional check when setting
$new_value['end_date']because a constraint may cause the$new_value['dates_collection']array to be empty. In such instances,$end_date = end($new_value['dates_collection'])returnsfalseand thereforeisset($end_date) = true. By checking that$end_dateis indeed an instance ofDateTime(and notfalse) we ensure that$end_date->format('Ymd')doesn't throw a fatal error.