Leveraging the Core Processor
... going on? We map the UserApi to a new User object and save the new
User... which causes Doctrine to assign the new id to that entity object. But
we never take that new id and put it back onto our UserApi.
To fix this ...
Filtering Relation Collection
... the published ones.
Side note: one downside to this approach is that if a user has 100 treasures...
but only 10 of them are published, internally, Doctrine will first query for all
100... even though we'll only return 10 ...
Clean URLs with Sluggable
...
behavior from Doctrine Extensions.
Head back to config/packages/stof_doctrine_extensions.yaml and add
sluggable: true.
Once again, this enables a listener that will be looking at
each entity, whenever one is saved, to see if ...
Auto-complete Association Field Controlling the Query
... now looking at the profiler for the autocomplete AJAX call. Head over to
Doctrine section so we can see what that query looks like. Here it is. Click "View
formatted query". Cool! It looks on every field to see if it ...
AssociationField for a Many Collection
... of this
relationship... for you Doctrine geeks out there.
Ok, try removing "95" again and saving. Hey! We upgraded to an error!
An exception occurred ... Not null violation: ... null value in
column question_id of ...
Themed Pagination Links
... .. then
/3! So cool!
Ok team! Congratulations on finishing both Doctrine courses! Big team high five!
Doctrine is one of the most important parts of Symfony and it will unlock you
for almost anything else you do. So let us ...
Saving Items in a ManyToMany Relation
... the second tag to that same question. How cool is that?
We simply relate the objects in PHP and Doctrine handles inserting the rows into
the join table.
If we saved all of this stuff and then, down here, said
$question ...
The Answer Entity
Oh hey there friends! Welcome back to part 2 of our Doctrine in Symfony series...
you wonderful database nerds you.
Last time we mastered the basics, but good stuff! Creating an entity, migrations,
fixtures, saving ...
Custom Filter getDescription properties
... Doctrine ORM... it's actually impossible to see which
one we have here... so I'll randomly guess:
Hey! I got it! If you chose the wrong one, you'll have to delete your project and
start over. Or... just delete this one ...
Setting a Custom Field Via a Listener
...
null if the user isn't logged in:
If there is no user, just return. But if there is a user, call
$user->setIsMe(true):
Cool! We just set the $isMe field on the authenticated User object. One cool
thing about Doctrine is ...
Foundry Tricks
... fixtures:
Then... refresh the homepage.
All good! If we dug into the database, we'd find 20 published questions and five
unpublished. Foundry can do more - especially with Doctrine relations and testing -
and we'll talk ...
Fetching Data The Repository
... findOneBy(). Pass this an array of the WHERE
statements we need: 'slug' => $slug. After, dd($question).
Ok, let's see what this returns! Refresh and... woohoo! This gives us a Question
object. Doctrine finds the matching row ...
Migrations
We have a beautiful new Question entity class that is supposed to map to a
question table in the database. But... that table does not exist yet.
How can we create it?
Well, because Doctrine has all of this configuration ...
Fixing our Deprecations Form Controller Mailer
... all the
ones from doctrine/persistence because they're not related to Symfony.
With that in mind... if you look closely, there are really only two real
deprecations left... and they look like the same thing: something ...
AMQP Priority Exchange
... bound to.
This did work before with Doctrine, thanks to this queue_name: high option.
The default value for this option is... default. As a reminder, I'll quickly
log into my database ...
Adding the plainPassword Field
... do this is via a Doctrine event listener or
entity listener, which are more or less the same thing. That's a fine option...
though things can get tricky when a user is updating their password. We talk
about that on an ...
High Priority Transports
... Let's use the same DSN as before, which in our
case is using doctrine. Below, add options, then queue_name set to high.
The name high isn't important - we could use anything. The queue_name option
is specific to the ...
Worker Command
Even if I refresh the page, now that our messages aren't being handled immediately...
the four most recent photos don't have Ponka in them. That's tragic! Instead, those
messages were sent to the doctrine transport and ...
Validation
... a database error
because of a new feature where validation rules are automatically added by reading
the Doctrine database rules.
But, whether you're seeing a 500 error, or Symfony is at least adding some basic ...
Filtering Searching
... support Doctrine ORM and Doctrine with MongoDB. Make sure to choose
the class for the ORM.
Ok, now move over and refresh again.
We're back to life! Click "Try it out". Hey! We have a little isPublished filter
input box! If ...
2709
Doctrine
Filter Results