Update dependency cuyz/valinor-bundle to ^2.3.0#49
Merged
Conversation
f892d54 to
9cd9e6d
Compare
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 contains the following updates:
^2.2.0→^2.3.0Release Notes
CuyZ/Valinor-Bundle (cuyz/valinor-bundle)
v2.3.0Compare Source
Notable changes
HTTP request mapping support
The bundle provides automatic mapping of HTTP request values to controller
arguments using attributes. This feature leverages Valinor's mapping
capabilities to handle route parameters, query values, and request body data.
Lean more about HTTP request mapping in the library
documentation.
Note that Symfony provides a similar built-in solution, which makes use of
attributes like
#[MapQueryString]and#[MapRequestPayload]. This bundle canbring some additional features:
non-empty-string,positive-int,int<10, 100>and more.configurators.
system.
Basic usage
Using the
#[MapRequest]on a controller's method enables automaticmapping.
Arguments can be mapped from different sources:
#[FromRoute]attribute#[FromQuery]attribute#[FromBody]attributeBasic example:
Per-controller mapper configuration
You can customize the mapper behavior for a specific controller by
passing mapper configurators to the
#[MapRequest]attribute:APIs often need to define rules concerning the keys cases passed in the
request; this can be defined using the following configurators:
camelCase,PascalCase,snake_caseorkebab-case.camelCaseorsnake_case.Custom request mapping attribute
When multiple controllers share the same mapper configuration (date
formats, key case rules, etc.), a custom attribute can be created to
avoid repeating the same configurators on every controller.
This is done by implementing the
MapRequestAttributeinterfacedirectly:
It can then be used in place of
#[MapRequest]on any controllermethod:
Error handling
When mapping fails, the bundle throws an
HttpRequestMappingErrorexception with a
422 Unprocessable Entitystatus code. The errormessage includes all validation errors. Example:
Mapping all parameters at once
Instead of mapping individual query parameters or body values to
separate parameters, the
mapAlloption can be used to map all of themat once to a single parameter. This is useful when working with complex
data structures or when the number of parameters is large.
The same approach works with
#[FromBody(mapAll: true)]for bodyvalues.
Request object mapping
When a controller needs to access the original request object, it can be
directly added as an argument:
Note — by enabling the
valinor.http.convert_request_to_psrconfiguration, controllers can type-hint a PSR-7
ServerRequestInterfaceparameter instead of Symfony'sRequest. Thebundle will automatically convert the incoming Symfony request to a
PSR-7 instance.
This requires the
symfony/psr-http-message-bridgepackage to beinstalled.
Features
Configuration
📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR was generated by Mend Renovate. View the repository job log.