512 search results

Security Voter

…not the current user is allowed to EDIT this DragonTreasure object. DragonTreasureVoter will make that decision. Copy this and paste it down for securityPostDenormalize: So here's the deal: anytime that is_granted() is called - from anywhere, not just from API Platform - Symfony loops through…

6:13
Flash Message & Rich vs Anemic Models

…Symfony will remove them so that they won't render again on the next page load. By putting this in the base template, we can now set flash messages from anywhere in our app and they'll be rendered on the page. Pretty cool. Watch…

6:32
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…

7:46
configureCrud()

…by id descending. To do that, open DashboardController and, anywhere inside, go to Code -> Generate - or command+N on a Mac - select override methods and choose configureCrud(). The Crud object has a bunch of methods on it... including one called setDefaultSort(). That sounds handy…

5:38
QR Data & Scanning with an Authenticator App

…log in - well, it matches one of the tokens in our configuration. Specifically, we get the UsernamePasswordToken when we log in via the form_login mechanism. If we try going anywhere else on the site, it kicks us right back here. The only place we…

4:35
Toast Notifications

…and add another review. This time... that's super cool! And it means that we can, from anywhere, render the _toast.html.twig template and it will activate this behavior. Though... the positioning isn't what I was imagining. Before it disappeared, it was open…

10:14
Fixing External JS + Analytics Code

…it in your browser. It's minified... so pretty unreadable. Copy the source, close it, spin over to your editor and create a new file anywhere, like pizza.js... we're not going to actually use this. Paste the code, select it, then go back…

8:46
3rd Party JavaScript Widgets

…this... then go open templates/base.html.twig. Head to the bottom and paste this in the footer: right before the closing body tag... though you could put this anywhere. Cool: this gives us an a tag... which just says "New York weather". Then, my…

7:52
Fixing the Sweetalert Modal

…go forward and... it worked! Wait, I can't scroll... and nothing is clickable! Inspect element anywhere. Uh oh: a Sweetalert backdrop element is still there! It's invisible, but it's blocking the page! This is the exact same problem we just saw with…

7:14
Query Bus

… We're returning a value from our handler! This is not something that we've done anywhere else. Commands do work but don't return any value. A query doesn't really do any work, its only point is to return a value. Before we…

8:47
Deployment & Supervisor

…the middle... there's a spot that talks about supervisor. Copy the configuration file. We could put this anywhere: it doesn't need to live in our project. But, I like to keep it in my repo so I can store it in git. In..…

9:08
Querying for One Pet

…is to make it accessible anywhere by moving that stuff to a new function called get_connection. Let’s do that: function get_connection() { } With variables, you have to worry about scope and what you have access to. But functions can be called from anywhere

3:04
Bootstrapping the Bundle & Autoloading

…move the KnpUIpsum class into that directory. And yea, you could put this into a src/Service directory, or anywhere else you want. Oh, but this namespace will not work anymore. We need a namespace that's custom to our bundle. It could be anything…

7:21
Linking to EasyAdmin from Twig

…I love it! We see the icons here... and if we go anywhere else - like to an Answer's detail page - the icons are here too. At this point, we know how to generate a link to any EasyAdminBundle page. If I scroll up a…

5:01
Having Fun with the Menu

…but this time leave the label blank. So unlike sub-menus, which wrap menu items, you can just pop a section anywhere that you want a separator. Let's go check it out. Refresh and... very nice! Separator one says "Content"... and separator two gives…

3:25
2 Factor Authentication & Authentication Tokens

…do need to do. Start by copying the two_factor stuff. Then open up config/packages/security.yaml. This new config can live anywhere under our main firewall. I'll paste it after form_login... and we can remove this comment: it highlighted that 2fa…

8:33
Security Listener System & Csrf Protection

…a CSRF token... then, on submit, you validate that token. Let's do this. Anywhere inside your form, add an input type="hidden", name="_csrf_token" - this name could be anything, but this is a standard name - then value="{{ csrf_token() }}". Pass this the string…

6:40
When Authentication Fails

…to your users - you can do this. Open up config/packages/security.yaml. And, anywhere under the root security key, add a hide_user_not_found option set to false: This tells Symfony to not convert UserNotFoundException to a BadCredentialsException. If we refresh now... boom…

7:19
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…

7:50
Props: Passing Info into a Child Component

…dev tools are even more interesting! If you click on , you can still see the legend data, though, we're not using this anywhere at the moment. And when you click on , nice! You can see its props! We've just seen two…

4:49