Extending a UX Controller
…see if we can let the chart
load, wait 5 seconds, then update some data.
Start by assigning the chart to a property so we can use it anywhere:
this.chart = event.detail.chart.
Then, at the bottom, and a new method that will…
Form Theme Block Naming & Creating our Theme!
…Instead, open form_div_layout.html.twig and find the block there. Copy
that and, in register.html.twig, paste this anywhere.
Hmm - let's remove the wrapping
and see if this works! Deep breath - refresh!
I saw something move! Inspect the form and..…
Creating & Mapping Layouts
…Until we actually
included {% block layout %} in base.html.twig, the layout was loading...
we just weren't rendering it anywhere.
The takeaway is this: if you're on a page that does not map to a layout, everything
is exactly the same as always…
Persisting to the Database
…with
DateTime objects. Let's say new \DateTime() and add some randomness here too:
sprintf('-%d days') and pass a random number from 1 to 100.
So, the askedAt will be anywhere from 1 to 100 days ago.
Ok! Our Question object is done! Add…
Vue Instance & Dynamic Data
…does exactly what Vue normally does. If you look at this, you might start to wonder:
why do we need a template option at all? We're just reading it in render()...
so it could live anywhere. Let's try that! Remove the option, and…
Database Tricks on SymfonyCloud
…out of SSH, and run:
symfony tunnel:open
I love this feature. Normally, the remote database isn't accessible by anything
other than our container: you can't connect to it from anywhere else on the
Internet. It's totally firewalled. But suddenly, we can…
Twig ❤️
…See this Welcome? No surprise, that's the
current title of the page.
Because this is surrounded by a block, we can override that in any template.
Check it out: anywhere in show.html.twig, add {% block title %}, Question,
print the question, then {% endblock %}.
This…
Filtering to Return only Approved Answers
…So... let's
do that!
In the Question class... anywhere, but right after getAnswers() makes sense,
create a new function called getApprovedAnswers(). This will return a Collection,
just like getAnswers(): Collection is the common interface that ArrayCollection
and PersistentCollection both implement.
Inside, we're going…
Global RESTful Exception Handling
…name. And we don't need to have
a return statement anymore: just call the function and it'll throw the exception
for us:
Re-test everything:
Now we're green and we can send back exciting error responses from anywhere in our
code. But…
Handling 404's + other Errors
…It's so nice when things work.
What we just did is huge. If a 404 exception is thrown anywhere in the system,
it'll map to the nice Api Problem format we want. In fact, if any exception is
thrown it ends up with…
Behat for Testing
…To see it, run
the same command with a -dl option:
$ php vendor/bin/behat -dl
Anywhere you see the quote-parentheses mess that’s a wildcard
that matches anything. So as long as we write scenarios using this language,
we can test without…
Block Plugins
…the page...
absolutely nothing happens! We added those options... but we're not using them
anywhere yet. We need to override a template to do that.
Let's think: we want this top and bottom margin to apply to every block in the
system. And…
Frontend Item View
…or, in a little while, we could choose to manually
select the exact recipes to show. We can also now embed lists and grids of
recipes anywhere we want on the site.
To celebrate, remove the entire latest_recipes Twig block:
And, up in MainController…
Enhanced Docker Integration & Testing Emails
…Refresh, add a fake email address, register, and... it worked! Of course, it didn't
send the email anywhere... but we can still see, more or less, what the email would
look like.
How? Click any link to go into the Profiler, click "Last 10"…
Reliably Load External JS with Stimulus
…At this point, we can add this anchor tag anywhere on our site,
and it will instantly do the work to initialize itself.
Next: let's investigate the second-use case for Turbo Frames... and really the
main use case: the ability to keep navigation…
Passing Props vs Fetching Directly
…talk about that in
our Vue 3 tutorial.
Anyways, in this situation, because categories is boring and static, it
doesn't really need to live as data anywhere. And that means, we do not need
to pass it down as props. If we want to…
x
511