Conversation
Like it says on the tin, this makes the User constructor protected. Also updates Post::author to use a Factory so class maps are supported when calling `Post::author()`.
we're dealing with a user object, not a post :P
#2153 add a test helper for auto-removing filters
I think this was applied to match the behavior of other other types (post, terms, ...), without thinking about a use case. But we will deprecate the Twig functions anyway and use the same function names that we use in PHP, see #2144. That would mean we should have a
We discussed this quite some time ago in #1689. My take is that we don’t need UserCollections, because the loop isn’t involved and usually we don’t need pagination. The same goes for Terms. In case we ever need that in the future, we can add it later. I will have a thorough look at this later this week. |
|
👍
Yes, I will write one up 👍 |
gchtr
left a comment
There was a problem hiding this comment.
Omg, with factories, the code looks soo clean 🤩.
I added a first couple of comments.
I will come up with a separate pull request for additional inline documentation.
PHP below 7.2 does not support argument type declaration of `object`.
|
@gchtr I just got all unit tests passing for this locally. Per discussion on #2157 I'm dropping support for Co-Authors Plus for now, as I just don't have time to continue supporting it. Discussion can continue on that PR, where the How are you feeling about this PR? |
gchtr
left a comment
There was a problem hiding this comment.
This looks good to me!
- I’m okay with dropping support for Co-Authors Plus and added a note in the Upgrade Guide in ffd474d. As you said, we can always come back later for trying to add support.
- I added two more tests for the factory in 6995c6f.
- I added a User Guide in #2167.
- I added DocBlocks improvements for User Factories in #2168.
This comment was marked as outdated.
This comment was marked as outdated.
|
Extensive work here @acobster! I found a few tiny things, but overall this is looking super. Take a look and let me know if you agree with my one substantive change (returning
|
|
... and also to close the loop on CoAuthorsPlus. I think #2157 is the perfect place to either resolve or abandon attempting to make it compatible. Let's not let that block us here |
2.x User factories DocBlocks
|
@jarednova yeah, I'm assuming the magic Timber getters will still return Thanks for adding those tests, looking good 👍 |
|
Awesome, feels great to get this merged! |
1 similar comment
|
Awesome, feels great to get this merged! |
Ticket: #2073 #2088 #2094
Issue
Updating the Users API per discussion in #2073.
Solution
Extensive discussion of the solution is in #2073 and #2093. In short:
Timber::get_userandTimber::get_users()no longer take a$UserClassarg; users must now rely on thetimber/user/classmapfilter to achieve polymorphic instantiation.timber/user/classmap.Impact
Discussed in docs.
Usage Changes
Also discussed in the docs.
Considerations
I'm not sure what the new usage of the Twig
{{ User(...) }}fn should be. Currently it supports arrays of IDs, which seems a bit astonishing. I'd be in favor or dropping support for this, or at least deprecating that use-case and providing a new{{ Users(...) }}(or{{ UserCollection(...) }}?) function.Speaking of which, do we need a
UserCollectionclass? I kind of assumed in the back of my mind that we'd want Collections for Users and Terms (we already haveCommentThread), but thinking more critically about it, the Loop is the main reason we havePostCollection, and there's not really an analog to that with Users or Terms. I could see there being a use-case for pagination or some other advanced query-related stuff, but I'm not sure. Thoughts?Edit: oh, and I'm hoping one of you can look at #2157 before we merge this in. :)
Testing
Tests have been refactored and removed where appropriate. The
UserFactoryclass has some prety thorough tests as well. It would be great add to tests for any edge cases y'all can think of.