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…
HTML dialog for Modals
…Actually, we can put it down here on
the dialog. Add a new action: click->modal#clickOutside:
I bet that looks odd - it'll be called whenever we click anywhere in the dialog -
so let's go write that method. Say clickOutside(), give it an…
The Request Object
…Request object. And there are two ways to get it.
The first is by autowiring a service called RequestStack. Then you can get the
current request by saying $requestStack->getCurrentRequest().
This works anywhere that you can autowire a service. But in a controller, there's…
All About services.yaml
…service ID. This is done for simplicity... but also for
autowiring. When we try to autowire MixRepository into our controller or anywhere
else, to figure out which service to pass us, Symfony will look for a service
whose ID exactly matches App\Service\MixRepository. So…
Security Voter & Entity Permissions
…do have control over that query. Open up UserCrudController and, anywhere,
I'll go near the top, override a method from the base controller called
createIndexQueryBuilder().
Here's how this works: the parent method starts the query builder for us. And it
already takes into…
Customize Error Messages & Adding Logout
…intercept that request, log out the user,
and redirect them somewhere else.
To activate that magic, open up config/packages/security.yaml. Anywhere under our
firewall, add logout: true:
Internally, this activates a "listener" that looks for any requests to /logout.
And actually, instead of…
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…
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"…
Page Context "Service"
…need anything to re-render when it changes. That's why it's totally legal
to grab this value in sidebar.vue or anywhere else that needs it.
But I want to kind of future proof our app... and plan ahead for a future
where…
Product Details & Smart vs Dumb Components
…now that we're loading data via Ajax, we need a way to tell the user
that things are loading... not that our server is on fire and they're waiting for
nothing. Let's create a Loading component that we can re-use anywhere.
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…
Private Variables & WeakMap
…it's not attaching any listeners
or adding itself as a reference to anything in the code. In other words, this object
is not attached or referenced anywhere in memory. Because of that, RepLogApp
objects - and their Helper objects - should be eligible for garbage collection…
Map and WeakMap
…southernUSStates to null:
When you try it now, this of course prints "undefined". That makes sense: we're now
passing null to the get() function.
But what you can't see is that the southernUSStates object no longer exists...
anywhere in memory!
Why? In JavaScript…
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…
Input DTO Validation
…at the bottom, after executing validation, it gets back
these "violations" and throws a ValidationException. This is a special exception
that you can throw from anywhere to trigger the nice validation error response.
So... let's go see it! At the browser, hit Execute and…
Custom Filter, getDescription() & properties
… We already know how! Back in CheeseListing, we've done this
before with other filters. Anywhere in here, add @ApiFilter() with
CheeseSearchFilter::class:
Unfortunately, PhpStorm doesn't auto-complete that for me... so I'll copy the class
name and add it on top manually…
Embedded Images
…if it's small. When you
embed, the image doesn't need to be hosted publicly anywhere because it's literally
contained inside the email.
Next, I already mentioned that the style tag doesn't work in gmail... which means
that our email will be…
Context Builder: Dynamic Fields/Groups
…test again:
This time... it passes! Context builders are awesome.
Though... they do have one downside: the dynamic groups are not reflected anywhere
in the documentation. Refresh the docs... then open the GET operation for a single
User. The docs say that this will return…
Logout & Passing API Data to JS on Page Load
…small HTML to bootstrap the Vue app... though I am doing
one interesting thing: I'm passing a prop to Vue called entrypoint. I'm not using
this anywhere... but it's a cool example: entrypoint is the URL to our
documentation "homepage". In theory…
x
512