andWhere() and orWhere()
…ve ever used it! And... you shouldn't either. Using andWhere()
is always ok - even if this is the first WHERE clause... and we don't really
need the "and" part. Doctrine is smart enough to figure that out.
What's wrong with ->where()? Well…
And WHERE Or WHERE
…cat:
The only thing our query needs is a WHERE clause to match the term to the
name of the Category. Let's chain!
Use a function called andWhere(). Don't worry - Doctrine won't add an
AND to the query, unless it's needed…
Generating URLs
Most of these links don't go anywhere yet. Whatever! No problem! We're going to
fill them in as we continue. Besides, most of our users will be in hypersleep for
at least a few more decades.
But we can hook up some of…
Actions: Listening to Events
I want to make our controller more realistic: instead of being able to click
anywhere on the element to increment the count, let's add a button.
Easy enough! In the template, add
Migrating Encore -> AssetMapper
…bunch of interesting things. We won't go too deep into how
AssetMapper works - we have other tutorials for that - but let's explore.
In .gitignore:
it ignores the final location of the built assets and where
the vendor files live. And in templates/base…
encore watch & Code Splitting
…filenames? When you build Encore for production,
those will be very simple names, usually a number - like 55.js. It won't expose
all these path details.
Next let's figure out how and where stimulus is installed and build our very
first stimulus controller!
Listening & Publishing
…which is the template that
holds the entire reviews turbo frame. At the top, or really anywhere, add a div.
Where its attributes live, render a new Twig function from the UX library we
installed a few minutes ago - turbo_stream_listen() - and pass this…
Collection Magic with Criteria
…you can chain off of this. The Criteria object is similar to the QueryBuilder
we're used to, but with a slightly different, well, slightly more confusing syntax.
Add andWhere(), but instead of a string, use Criteria::expr(). Then, there
are a bunch of methods…
Filters
…cookie company, that means we don't
make them anymore. But we're not showing this information anywhere on the
frontend yet.
But what if we wanted to only show fortune cookies on the site that we're
still making? In other words, where discontinued…
Reusing Query Logic & Param Converters
…you can reuse query logic between them. For example, a lot
of queries might need this andWhere('q.askedAt IS NOT NULL') logic. That's not
complex, but I would still love to not repeat this line over and over
again in every method and…
Multiple Submit Buttons
…If we change price to IntegerType::class, when we refresh the form,
nothing will change, because that was the guessed type.
But what built-in form field types does Symfony have and where can we find
them? Great question, and I'm glad you asked…
Bonus: Messenger Monitor Bundle
…When you have a bunch of messages and schedules running in the background,
it can be hard to know what's happening. Are my workers running? Is my schedule
running? And where is it running to? What about failures? I mean, we have logs,
but..…
Criteria: Filter Relation Collections
…of an entity. Fortunately, we can move
it there.
Because this deals with fortune cookies, open
FortuneCookieRepository and, anywhere, add a new public static function called...
how about createFortuneCookiesStillInProductionCriteria(). This will return a
Criteria object.
Now, grab the $criteria statement from the entity... and return…
Webpacking our First Assets
…the final, built files and the second - setPublicPath() -
tells it the public path to this directory:
The third important piece, and where everything truly starts, is addEntry():
Here's the idea: we point Webpack at just one JavaScript file - assets/js/app.js.
Then, it…
Modal Twig Component
…a good day. Today we get to combine our modal system with Twig components
to achieve a goal! I want to be able to quickly add a modal anywhere in our app.
Start in base.html.twig. All the way at the bottom, copy the…
Sending Handlers to Different Transports: from_transport
…option I want to mention is interesting... but can also be confusing.
It's called from_transport.
If you look at messenger.yaml, this DeleteImagePost isn't being routed
anywhere, which means it's handled synchronously. Let's pretend that we want to
handle it…
All about Event Bubbling
I'm feeling so good about our first click listener, let's add another! When I click
anywhere on a row, I also want to log a message.
Back in the template, give the entire table a js class so we can select it. How…
Modular CSS
…right inside the component. In products.vue,
we render an element with a sidebar class... and then immediately - without going
anywhere else - we're able to add the CSS for that. We can still have external
CSS files with shared CSS, but for any styling…
RESTful APIs in the Real World Course 1
…PUT, PATCH, DELETE
Idemptotency and safe methods
Proper Status Codes, Location header and Content-Type
Testing your API
RFCs and where the "rules" come from
Advanced error and validation handling
If you want to know about Hypermedia, HATEOAS,
Content-Type negotiation, pagination and more, these…
Generate URLs
Go back to the "show" page for a question. The logo on top is a link... that doesn't
go anywhere yet. This should take us back to the homepage.
Because this is part of the layout, the link lives in base.html.twig. Here…
x
512