Rewrite v7 find-user-by-identity tutorial - #171
Merged
Conversation
The v5 handler shape, `Api\App` namespaces and `setMessages()` no longer exist; the endpoint is now a `#[Resource]` attribute resolved by ResourceProviderMiddleware. Signed-off-by: arhimede <julian@dotkernel.com>
alexmerlin
approved these changes
Sep 8, 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.
Audit finding C7. The tutorial was still a v5 page: every class, namespace and API in it is gone.
Verified against
dotkernel/apibranch7.0at45ad282.What was wrong
$app->get('/user/' . $id, UserHandler::class, 'user.view')$routeCollector->group('/user/' . $id)->get('', GetUserResourceHandler::class, 'user::view-user')UserHandlerwith aget()methodGetUserResourceHandlerwithhandle()use Api\App\Handler\HandlerTrait;Api\App\Handler\AbstractHandleruse Api\App\Message;Core\App\Messageuse Api\User\Entity\User;Core\User\Entity\User(new BadRequestException())->setMessages([...])setMessages()exists nowherethrow new NotFoundException(Message::USER_NOT_FOUND)NotFoundException::create(...)UserRole::ROLE_GUESTUserRoleEnum::Guest->value$messages['error']['messages'][0]detailroute:list::names, four-column tableWhat the page does now
It follows the endpoint it claims to follow. In v7
GetUserResourceHandlernever queries the database —ResourceProviderMiddlewarereads the#[Resource]attribute offhandle()and loads the entity. So the new endpoint is one attribute:which the middleware turns into
findOneBy(['identity' => ...]), throwingNotFoundExceptionitself when nothing matches. The old page'sBadRequestExceptionbranch was unreachable in any version —/user/matches no route.Also corrected:
factoriesanddelegators => [HandlerDelegatorFactory::class]. Without the delegator,$responseFactorystaysnullandcreateResponse()fails./user/{id}is UUID-constrained and{identity}is not, so a UUID matches both; static paths like/user/rolewere never at risk.MetadataMapneeds no new entry —_links.selfstill points at/user/{uuid}.markdownlintclean, one sentence per line.