1000 search results

Completely Custom Resource

…types, which will also help API Platform's documentation. More on that soon. Or, if you don't want this stuff to be public, use the normal private properties with getters and setters: whatever you want. To officially make this an API Resource class, above…

5:25
Input DTO Class

…needed anymore because we have moved all of this stuff. Delete both: There is now nothing inside of CheeseListing about serializing or deserializing. Ok! Our CheeseListingInput is ready! To tell API Platform to use it, it's the same as output. On CheeseListing, add input=…

7:16
DTO Quirks: Embedded Objects

…on a related object will be serialized, then API Platform should return an array of IRI strings instead of embedding the objects. This is a bug in how the readableLink for properties is calculated when you have a DTO. I've actually fixed this bug…

6:37
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
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
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
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
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
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
Creating Embedded Objects

…create and save these objects, I'd probably just find where that CheeseListing is being created and call $entityManager->persist() on it. But because API Platform is handling all of that for us, we can use a different solution. Open User, find the $cheeseListings property…

7:06
@SerializedName & Constructor Args

…anyone using our API. It's pretty easy to guess how these properties are created: the keys inside the JSON literally match the names of the properties inside our class. And in the case of a fake property like textDescription, API Platform strips off the…

7:15
On Authentication Success

…to /api/users/5? Typically in Symfony, we create the route and then we can generate a URL to that route by using its internal name. But... now, API Platform is creating the routes for us. Is there a way with API Platform to say…

7:40
Adding the plainPassword Field

…when a user is updating their password. We talk about that on an older Symfony 3 Security Tutorial. We're going to try a different approach - an approach that's more specific to API Platform. Before we get there, let's write a test to…

7:31
Leveraging the Doctrine Data Provider

…down at getCollection(): it creates a query builder and then loops over something called the "collection extensions". This is the Doctrine extension system in API Platform, and these extensions are actually what is responsible for changing the query to add things like pagination and filtering…

5:27
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
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
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
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
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