Decorating the CollectionProvider
... they've decided
to rebel! Let's pop open the failed response. Hmm:
More than one result was found for query, although one row or none was expected.
If you view the page source, this is coming from Doctrine... and eventually ...
Using GROUP BY to Fetch Count in 1 Query
... Doctrine Query. This stuff is just weird, cool and fun. I hope you enjoyed
it as much as I did. If you encounter any crazy situation that we haven't thought
about, have any questions, or pictures of your cat, we're always here for you
down in the comments. Alright, see you next time!
SELECT the SUM or COUNT
... fortuneCookie.categoryId = and then the integer ID. But in Doctrine, we don't
think about the tables or columns: we focus on the entities. And, there is no
categoryId property on FortuneCookie. Instead, when we say ...
State Processors Hashing the User Password
... deserialized onto the User object, but before it's saved.
In our tutorial about API platform 2, we used a Doctrine listener for this,
which would still work. Though, it does some negatives, like being super
magical - it's ...
Query Extension Auto-Filter a Collection
...
Except... that won't quite work. Why? The CollectionProvider from Doctrine executes
the query and returns the results. So all we would be able to do is take those
results... then hide the ones we don't want. That's ...
Embedded Write
... Doctrine failed because we never told it to persist
the new User object.
Though... that's not the point: the point is that we don't want a new User!
We want to grab the existing owner and update its username.
By the way, to ...
Relating Resources
... our Doctrine tutorial. But since this isn't on production,
we can cheat and just to turn the database off and on again. To do that run:
symfony console doctrine:database:drop --force ...
Filters Searching Results
... called BooleanFilter that we'll use now and another called
SearchFilter that we'll use in a few minutes.
Pass this BooleanFilter - the one from ORM, since we're using the Doctrine ORM -
because we want to allow the user ...
Operations Endpoints
API Platform works by taking a class like DragonTreasure and saying that you want
to expose it as a resource in your API. We do that by adding the ApiResource
attribute:
Right now, we're putting this above a Doctrine ...
Swagger UI Interactive Docs
... is that our API did return a list of all of the DragonTreasures we
currently have, which is just this one.
So in just a few minutes of work, we have a fully featured API for our Doctrine
entity. That is cool.
Copy the ...
Builder in Symfony with a Factory
... actually have Doctrine installed
in this project, so instead of the EntityManager, let's require
LoggerInterface $logger... and I'll again add private in front to turn that into
a property:
Then, down in buildCharacter ...
Adding new Properties
... doctrine:migrations:list
you'll see that it recognizes both migrations and it knows that it has not
executed the second one. To do that, run:
symfony console doctrine:migrations:migrate
Doctrine is ...
docker-compose Exposed Ports
... be super easy.
To start, remember when the Doctrine recipe asked us if we wanted Docker
configuration? Because we said yes, the recipe gave us docker-compose.yml and
docker-compose.override.yml files. When Docker boots ...
Extending with Events
... go to any
question... it says "Updated By", "Null". Our goal is to set that field automatically
when a question is updated.
A great solution for this would be to use the doctrine extensions library and
its "blameable ...
When a Migration Falls Apart
...
not required: it does allow null... which is not what we want. But fixing
this is easy: ask Doctrine to generate one more migration:
symfony console make:migration
This is really ...
Type Validation
... must be an
int, string given.
This is cool. When the deserializer does its work, it first tries to figure
out what type the field should be, which we know it does in a number of different
ways, like reading Doctrine ...
Output Properties Metadata
... know
what type title will be.
And... that's no surprise! When we serialize a CheeseListing entity, API Platform
can use the Doctrine metadata above the title property to figure out that it's a
string:
But in this case ...
Custom Filter for Custom Resources
... difference is that the apply() method has different arguments
than filterProperty()... which makes sense because that method was all
about querying via Doctrine.
Before we start filling this in, go to src/Entity ...
Custom Resource PUT Operation
... we added a bunch of built-in filters to allow users to
search and filter the results:
But what if the built-in filters aren't enough? What if we need to add some
custom filtering logic? Let's do that next by first creating a custom filter
for a Doctrine entity and later creating a custom filter for our DailyStats
resource.
Custom Paginator
When an API resource is a Doctrine entity like CheeseListing, life is good!
We get tons of things for free, like pagination, access to a bunch of pre-built
filters and one time I swear I got free pizza.
But... these ...
2708
Doctrine
Filter Results