1000 search results

Validation Groups

…plainPassword field isn't persisted to the database, at the beginning of each request, after API Platform queries the database for the User, plainPassword will always be null. If an API client only sends the username field... because that's all they want to update..…

5:44
Pagination

…s because API Platform shows 30 results per page, by default. Because I don't feel like adding 20 more manually, this is a great time to learn how to change that! First, this can be changed globally in your config/packages/api_platform.yaml…

4:34
Filtering & Searching

…by title? These are called "filters": ways to see a "subset" of a collection based on some criteria. And API Platform comes with a bunch of them built-in! Let's start by making it possible to only return published cheese listings. Well, in a…

6:02
Serialization Tricks

…refresh, and check out the POST endpoint. The field is gone. API Platform sees that we have a treasureName argument that could be sent, but since treasureName doesn't correspond to any property, that field doesn't have any serialization groups. So it's not…

5:15
React Admin

…all the details, even including CORS config if you have that problem. So... let's do this! If you use the API Platform Docker distribution, this admin area comes pre-installed. But it's also easy enough to add manually. Right now, our app doesn…

9:20
Relating Resources

API and instantly see what treasures it has. Anyways, the property - dragonTreasures inside of User is fine.... and finally, for orphanRemoval, say no. We'll also talk about that later. And... done! Hit enter to exit. So this had nothing to do with API Platform

7:08
Query Extension: Auto-Filter a Collection

…to modify the query for a collection endpoint, we're going to create something called a query extension. Anywhere in src/ - I'll do it in the ApiPlatform/ directory - create a new class called DragonTreasureIsPublishedExtension. Make this implement QueryCollectionExtensionInterface, then go to "Code"->"Generate…

6:15
Custom Resource State Processor

…I love it! Speaking of that Patch operation, when it's used, API Platform will call the state processor, so we can save... or do whatever we want. We don't have one yet, so that'll be our next job. But let's start…

6:48
Running Code "On Publish"

…processors. The make:state-processor command created the process() method with a void return. And... that makes sense. API Platform passes us the data and our job is just to save that... not return anything. However, technically the process() method can return something. And, for…

6:05
Pagination on a Custom Resource

…number per page is still 30 and the offset is 30. Where is it getting 30 as the items per page? That's the default in API Platform for any resource. But this is something you can configure on your #[ApiResource] attribute: change paginationItemsPerPage to…

8:18
Filtering the Products

…done a bit of work behind the scenes in API platform to allow us to fetch all the products for a specific category. Here's how it works: we can enter a category's IRI into this box: so, /api/categories/ - and then 24 to…

4:51
Ajax with Axios

…for GET /api/products. The best way to see how this works is... to try it! Let's see... hit Execute and... here's the response body. We already have a set of products in the database. If you haven't used API Platform before …

5:41
Filter Autowiring

…option and sets those as named arguments on that service. Why do we care about how our filter objects are instantiated? Because when API Platform registers the service, it also sets it to autowire: true. Yep, this means we can access services in our filter…

5:46
Type Validation

…argument is not nullable, if you tried to send a price field set to null that value would not be legal to set on this property. When this happens, API Platform returns a 400 error. It's not a validation error exactly... but it effectively…

7:29
Input DTO Update Problems

…when the serializer deserializes the JSON into the CheeseListingInput, the owner property will be null... and then we pass that null value onto $cheeseListing->setOwner(). When API Platform tries to save the CheeseListing with no owner... error! But... let's back up: there's a…

6:38
Output Properties & Metadata

…This is referring to the "models" at the bottom of the page. Scroll down to see them. API Platform creates a unique "model" for each different way that a resource might be returned based on your serialization groups. And when you create an output DTO…

7:14
Custom Resource GET Item

…we kind of added the get item operation... but we made it return a 404 response: We did that as a workaround so that API Platform could generate an IRI for DailyStats. Now I want to make this truly work. Remove all of the custom…

5:50
Custom Resource Data Provider

…is that, inside DailyStats, we've specifically said that we don't want any item operations: This kind of confuses API Platform, which has a brief existential crises before saying: How can I generate a URL to the item operation if there aren't any!…

6:40
Core Listeners & Accessing the "Resource" Objects

…it does have two downsides, which may or may not be important. First, the event system isn't used in API Platform's GraphQL support... so this won't work if you're using GraphQL. And second, if you're writing some custom console commands…

4:37
Adding & Populating the Custom Field

…property... there it is... we can add more docs: Returns true if this is the currently-authenticated user That's nice because API Platform will automatically use this in the docs. When we look at the schema now on the user operation... there it is…

5:10