Skip to content

Conversation

@Valmonzo
Copy link
Owner

No description provided.

Copy link

@mtarld mtarld left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First round 😉

// We must trigger the API Platform validator before the data transforming.
// Let's create an API Platform PR to update the AbstractItemNormalizer.
// In that way, this exception won't be raised anymore as payload will be validated (see DiscountBookPayload).
InvalidArgumentException::class => 422,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this still working without it? Maybe it has been fixed 🙂


$resources = [];
foreach ($models as $model) {
$resources[] = BookResource::fromModel($model);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ObjectMapper has been integrated into API Platform, I think it could be great to use it here (and in other providers/processors).
To get inspiration, you can have a look at ObjectMapperProvider and ObjectMapperProcessor in API Platform's code.

/** @var string $id */
$id = $uriVariables['id'];

$model = $this->queryBus->ask(new FindBookQuery(new BookId(Uuid::fromString($id))));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to remove the query bus for simple use cases like that and use the repository directly.
But maybe it's for a next PR

Comment on lines -26 to -27
*
* @return T
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why removing it?

Comment on lines -26 to -27
*
* @return T
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

final readonly class AuthorFilter implements FilterInterface
{
#[\Override]
public function getDescription(string $resourceClass): array
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is deprecated in 4.2.

I think we should add a job checking that we have no deprecations, but same, for another PR!

use ApiPlatform\Metadata\FilterInterface;
use Symfony\Component\TypeInfo\TypeIdentifier;

final readonly class AuthorFilter implements FilterInterface
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'author' => [
'property' => 'author',
'type' => Type::BUILTIN_TYPE_STRING,
'type' => TypeIdentifier::STRING->value,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It could be great to validate the type with: https://api-platform.com/docs/core/filters/#parameter-validation

Comment on lines 44 to 59
$resources = [];
foreach ($models as $model) {
$resources[] = BookResource::fromModel($model);
}

if (null !== $paginator = $models->paginator()) {
$resources = new Paginator(
new \ArrayIterator($resources),
(float) $paginator->getCurrentPage(),
(float) $paginator->getItemsPerPage(),
(float) $paginator->getLastPage(),
(float) $paginator->getTotalItems(),
);
}

return $resources;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that with the ObjectMapper use, this won't be needed anymore 🎉

Comment on lines +17 to +18
- caddy_data:/data
- caddy_config:/config
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- caddy_data:/data
- caddy_config:/config
- caddy_data:/data
- caddy_config:/config

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants