Repository navigation
refactor: keep block bindings free of Laravel before they become a package - #492
Merged
Merged
Conversation
…ckage The resolver takes a PSR-11 container; two contracts carry what Laravel did for it (MethodInvokerInterface for the parameters of a source's method, BindingEventsInterface for BindingResolved); the options a project lists reach OptionSource and the editor data as an array; labels and names come from Naming; the Laravel side (provider, doctor check, commands) moves to Pollora\BlockBinding\Infrastructure\Laravel. Pages, REST responses and command outputs of pollora-test are identical to the references taken before.
BindingContext::post() asked the framework's Post model; a PostFinderInterface now gives it (the framework's Post under Laravel, Colt's without it), so the context no longer reaches the framework. The captures of pollora-test are still identical.
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.
Step 1 of the extraction of
pollora/block-bindings(plan:.claude/plans/meta-roles-bindings-packages.mdin pollora-test).BindingResolvertakes a PSR-11ContainerInterface(get()autowires under Laravel). Two new contracts carry what Laravel's container and events did for it:MethodInvokerInterface(the method of a#[BlockBinding]source gets the services its typed parameters name, the binding context by its type or as$context) andBindingEventsInterface(BindingResolved).LaravelMethodInvokerandLaravelBindingEventsimplement them for Laravel;ReflectionMethodInvokeris the default without it. How a source is declared and written does not change.OptionSourceandBindingEditorDatatake the listed options as an array, read fromblock-bindings.optionsby the provider with explicit bindings (an autowired nullable or defaulted parameter would have silently become empty).Htmlablebecomesmethod_exists($value, 'toHtml');Str::headline()/snake()becomeNaming(pollora/attributes 0.1.1).Pollora\BlockBinding\Infrastructure\Laravel: provider, doctor check, the two commands and their stub.surface.jsonregenerated: the diff is the moved classes, the new contracts and the changed constructors.Checked: suite in sequence 1635 passed, PHPStan clean, Rector and Pint; the 28 captures of pollora-test (bindings resolved over REST for four sets, editor data,
binding:list, concert pages, roles, doctor…) are identical to the references taken before the change.Added after review of the code: a third contract.
BindingContext::post()asked the framework'sPollora\Models\Post(Eloquent model with the typed meta accessors).PostFinderInterfacenow loads it:LaravelPostFindergives the framework's model, so a source gets the same object as before; without Laravel it is Colt'sPost.post()is typed as Colt'sPost, which the framework's extends. Covered by a unit test and by the captures (identical).