feat: Add afterExtracting() hook for post-processing endpoint data#1072
Merged
Conversation
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.
Summary
This PR introduces a new lifecycle hook:
Scribe::afterExtracting(). This hook allows users to make programmatic changes to extracted endpoint data after all strategies have finished their execution, but before the data is finalized. Closes #1067Motivation
Previously, users who wanted to make small, context-aware changes to extracted data (like appending info to descriptions based on middleware or route names) had to either create a full custom strategy or use hooks intended for other purposes (like
beforeResponseCall). This new hook provides a clean, "middle-ground" solution for such cases.Changes
src/Tools/Globals.php: Added a static property$__afterExtractingto store the callback.src/Scribe.php: Added a public static methodafterExtracting(callable $callable)to allow easy registration of the hook.src/Extracting/Extractor.php: Integrated the hook call at the end ofprocessRoute(). It is called once for each route and receives theExtractedEndpointDataobject.Example Usage
In your
AppServiceProvideror a dedicated Scribe bootstrap file: