Increase template controller DI support#71
Merged
Conversation
added 13 commits
May 18, 2026 09:44
- Refactor parameter resolution into a SOLID, registry-based architecture using native PHP-DI chains - Add specialized context resolvers for Timber Post, Term, User, and PostType objects - Support nullable typehints while maintaining strict enforcement for type mismatches - Introduce Macroable proxies for Timber PostQuery, Term, User, and PostType to ensure ecosystem consistency - Bind TimberContext as a shared singleton Collection for cross-component data orchestration - Integrate view helpers and container-aware response instantiation into the base Controller
- Update context resolvers to support Timber 2 canonical patterns and subclasses - Implement config-driven resolver registration in WordPressControllersServiceProvider - Ensure correct resolver priority (User > Core > Router) by prepending to the chain - Add Macroable proxy classes for PostQuery, PostType, Term, and User - Implement full PHPUnit test suite for all new DI features and proxy objects - Fix missing imports and static state leakage in existing tests
- Optimized AbstractContextResolver loop to avoid collection overhead - Safeguarded PostTypeResolver against non-WordPress contexts - Cleaned up WordPressControllersServiceProvider by extracting core resolver list - Refactored PostQueryResolverTest to reduce repetition - Verified TimberResponse recursion logic and fixed missing Arr import
…eview - Optimized AbstractContextResolver loop to avoid collection overhead - Safeguarded PostTypeResolver against non-WordPress contexts - Cleaned up WordPressControllersServiceProvider by extracting core resolver list - Refactored PostQueryResolverTest to reduce repetition - Verified TimberResponse recursion logic and fixed missing Arr import
- DRYed up context resolvers by moving reflection and validation logic to AbstractContextResolver - Simplified concrete resolvers to implement canResolveClass and resolveObject - Added AbstractContextResolverTest to cover common DI edge cases (built-ins, nullables, mismatches) - Optimized existing resolver tests by removing repetitive boilerplate
- DRYed up context resolvers by moving reflection and validation logic to AbstractContextResolver - Simplified concrete resolvers to implement canResolveClass and resolveObject - Added AbstractContextResolverTest to cover common DI edge cases (built-ins, nullables, mismatches) - Optimized existing resolver tests by removing repetitive boilerplate
- Optimized WordPressControllersServiceProvider by defining core resolvers in priority order - Cleaned up AbstractContextResolverTest by using a shared test stub - Verified all DI resolver tests and linting
…lumberjack-core into feature/template-controller-di
added 9 commits
May 19, 2026 11:14
- Implemented Term::termClass() to resolve mapped taxonomy classes - Implemented User::userClass() to resolve mapped user classes via filters - Added comprehensive unit tests and verified 100% coverage on new methods
Collaborator
AliceKLWilliams
left a comment
There was a problem hiding this comment.
I believe you have removed the view method - can you update the MR description to remove that part.
AliceKLWilliams
approved these changes
May 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR introduces a robust context-aware Dependency Injection system for Template Controllers and adds Macroable proxy objects for Timber 2 alignment. Full backward compatibility is maintained; existing controller signatures and Timber integrations remain unaffected.
Controller Dependency Injection
Timberbase classes andRareloop\Lumberjackproxy classes (Post,Term,User,PostQuery).Rareloop\Lumberjackproxy objects is preferred to leverage addedMacroablesupport and framework-specific utilities.Post,Term,User,PostQuery(includingPostCollectionInterface).App\Post\Book) and nullable type-hints.AbstractContextResolverusing a Template Method pattern to centralize reflection, validation, and instance verification logic.app.resolversconfiguration support to allow user-defined resolver registration with precedence over core logic.Macroable Proxy Objects
Rareloop\Lumberjackproxy classes forPostQuery,Term, andUser. All proxies implement theMacroabletrait.Context Handling and Helpers
Rareloop\Lumberjack\Http\TimberContextcollection wrapping the default Timber context.get(),set(), andhas().ArrayAccess(offsetGet,offsetExists) to ensureIlluminate\Support\Arr::get()compatibility with dot-notation on the context object.TimberResponseto supportArrayableandCollectioncontext objects.Bootstrapping and Performance
WP_Queryinto the container inRegisterRequestHandler.TimberContextas a singleton inTimberServiceProvider.array_reversecalls on every resolution.