Ajax Element Reloading Controller
…an Ajax call to reload the product list area after a new product is successfully
added. To be extra cool - cause we are extra cool - we're going to make this
new controller generic so we can reuse it anywhere... like on the cart page…
Who Creates the Controller & Gives it the Container?
…they're the only services that we routinely make public.
If you look back at services.yaml, it's not immediately obvious why they're
public - I don't see a public: true anywhere. I'll save the details for the
next deep-dive tutorial…
Calling the Controller & View Event
…entity! You would return a "model". Then, you could write a listener
to this event that transforms that Article entity into HTML by rendering the template.
This event isn't used anywhere in Symfony's core, but it is used extensively
inside API Platform. Internally…
Annotations
…bring up all the options that you
have in that spot. In fact, "control+space" can be used pretty much anywhere to show
you your auto-complete option - really handy.
This autocomplete works for two reasons. First, an annotation represents a real class.
Hold command…
How to handle dynamic Subdomains in Symfony
…this be handled? Let’s find out together!
1) The VirtualHost¶
Before you go anywhere, make sure you have an Apache VirtualHost or Nginx
site that sends all the subdomains of your host to your application. Since
we’re using lolnimals.l locally, we’ll…
Turbo Streams: Update any Element
…count:
Copy that. When we search on the page, it's actually this that's navigating.
So anywhere inside this - I'll go to the bottom - we can add a .
Say:
Custom Entity Methods & Twig Magic
…the vote count. Pass these in: $prefix then the absolute value
of $this->votes... since we're adding the negative sign in manually.
We can now use this nice method anywhere in our app... like from inside a template
with mix.getVotesString(). Or shorten this…
Publish-Subscriber (PubSub)
…constructor arguments... it's
just not something I care about all that much. It does look cool though.
Down here, anywhere before our app actually starts, say $this->eventDispatcher->.
Notice that the only method this has is dispatch(). I made a... tiny mistake.
Let…
Review this Product... in a turbo-frame!
…we submit... gorgeous! Our new review even popped up right above
the form!
Though, hmm. There's no success message anywhere on the page. There was
one before... but now it's gone! What happened?
Look back at the network tools. There are two new…
Using a Full HTML Page to Populate a Frame
…In base.html.twig, scroll back down to
that area. Surround this in a new {% block weather_widget %} and, on the other
side, {% endblock %}.
Back in index.html.twig, anywhere, override that block... but make it empty.
Ok, refresh again and... cool!
At this point…
FlattenException & Error Status Codes
…which will be a 412 and many more.
Hmm, where's the IAmATeaPotHttpException?
If you throw any of these exceptions from anywhere in your app, they will trigger
an error page with the correct status code. This is a powerful thing to understand.
Back in…
SRP: Responsibilities
…code that
deals with hashing passwords and persisting user data? In a perfect world,
shouldn't I be able to create this "email resend" feature without going anywhere
near code that's unrelated to this functionality?
This is what SRP is trying to help us…
Support any Browser with PostCSS & Babel
…amazing... let's add it! In webpack.config.js, anywhere,
but how about below .enableSassLoader(), add .enablePostCssLoader():
PostCSS is a library that allows you to run things at the "end" of your CSS being
processed. And it's the easiest way to integrate autoprefixer.
Next…
Auto-Provide jQuery for Mischievous Packages
…is
already scanning all of our code. When you enable this feature, each time it finds
a jQuery or $ variable- anywhere in any of the code that we use - that is
uninitialized, it replaces it with require('jquery'). It basically rewrites
the broken code…