Skip to content

Commit 0eb372c

Browse files
committed
documentation updates & linting
Signed-off-by: MarioRadu <[email protected]>
1 parent 8a627fe commit 0eb372c

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

docs/book/v5/tutorials/find-user-by-identity.md

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
# Find user by identity - A practical example
1+
# A practical example: Find user by identity
22

33
## Our goal
44

5-
Create a new endpoint that fetches a user based on its identity.
5+
Create a new endpoint that fetches a user record by its identity column.
66

77
We already have an endpoint that retrieves a user based on their UUID, so we can review it and create something similar.
88

@@ -37,12 +37,12 @@ This command will list all available endpoints, which looks like this:
3737
### Note
3838

3939
> **The above output is just an example.**
40-
>
41-
> More info about listing available endpoints can be found [here](../commands/display-available-endpoints).
40+
>
41+
> More info about listing available endpoints can be found in `../commands/display-available-endpoints.md`.
4242
4343
The endpoint we're focusing on is the last one, `user.view`, so let's take a closer look at its functionality.
4444

45-
If we search for the route name `user.view` we will find its definition in the `src/User/src/RoutesDelegator.php` class, here live all user related endpoints.
45+
If we search for the route name `user.view` we will find its definition in the `src/User/src/RoutesDelegator.php` class, where all user related endpoints are found.
4646

4747
```php
4848
$app->get('/user/' . $uuid, UserHandler::class, 'user.view');
@@ -133,11 +133,11 @@ Our handler is very similar to the existing one, with some extra steps:
133133
* We store the identity from the request in the `$identity` variable for later use.
134134
* If the identity is empty we throw a `BadRequestException` with an appropriate message.
135135
* If we can't find the user in the database we throw an `NotFoundException`.
136-
* We generate and return the response.
136+
* If the record is found, we generate and return the response.
137137

138-
The next step is to register the new handler,
139-
to do this go to `src/User/src/ConfigProvider.php`
140-
and in the `getDependencies()` method under the `factories` key add `IdentityHandler::class => AttributedServiceFactory::class,`
138+
The next step is to register the new handler.
139+
To do this go to `src/User/src/ConfigProvider.php`.
140+
In the `getDependencies()` method under the `factories` key add `IdentityHandler::class => AttributedServiceFactory::class,`
141141

142142
Next, create the route in `src/User/src/RoutesDelegator.php`:
143143

@@ -158,7 +158,6 @@ The last step is to set permissions on the newly created route.
158158
Go to `config/autoload/authorization.global.php` and add our route name (`user.view.identity`) under the `UserRole::ROLE_GUEST` key
159159
This will give access to every user, including guests to view other accounts. (for the sake of simplicity)
160160

161-
162161
### Writing tests
163162

164163
Because every new piece of code should be tested we will write some tests for this endpoint also.
@@ -210,4 +209,4 @@ class IdentityTest extends AbstractFunctionalTest
210209
}
211210
```
212211

213-
Planning and coding a new feature can be challenging at times, but reviewing our existing code or tutorials can serve as a source of inspiration.
212+
Planning and coding a new feature can be challenging at times, but reviewing our existing code or tutorials can serve as a source of inspiration.

0 commit comments

Comments
 (0)