Chapters
33 Chapters
|
3:02:08
|
Login to bookmark this video
-
Course Code
Subscribe to download the code!Compatible PHP versions: ^7.2.0
Subscribe to download the code!Compatible PHP versions: ^7.2.0
-
This Video
Subscribe to download the video!
Subscribe to download the video!
-
Subtitles
Subscribe to download the subtitles!
Subscribe to download the subtitles!
-
Course Script
Subscribe to download the script!
Subscribe to download the script!
07.
A Great Place to Hide Things! The data- Attributes
Scroll down to the script below, click on any sentence (including terminal blocks) to jump to that spot in the video!
Subscribe to jump to this part in the video!
Keep on Learning!
If you liked what you've learned so far, dive in! Subscribe to get access to this tutorial plus video, code and script downloads.
This tutorial uses an older version of Symfony... but since it's a JavaScript tutorial, the concepts are still ? valid!
What PHP libraries does this tutorial use?
// composer.json
{
"require": {
"php": "^7.2.0",
"symfony/symfony": "3.1.*", // v3.1.10
"twig/twig": "2.10.*", // v2.10.0
"doctrine/orm": "^2.5", // v2.7.1
"doctrine/doctrine-bundle": "^1.6", // 1.10.3
"doctrine/doctrine-cache-bundle": "^1.2", // 1.3.2
"symfony/swiftmailer-bundle": "^2.3", // v2.4.0
"symfony/monolog-bundle": "^2.8", // 2.12.0
"symfony/polyfill-apcu": "^1.0", // v1.2.0
"sensio/distribution-bundle": "^5.0", // v5.0.22
"sensio/framework-extra-bundle": "^3.0.2", // v3.0.16
"incenteev/composer-parameter-handler": "^2.0", // v2.1.2
"friendsofsymfony/user-bundle": "~2.0@dev", // dev-master
"doctrine/doctrine-fixtures-bundle": "~2.3", // v2.4.1
"doctrine/doctrine-migrations-bundle": "^1.2", // v1.2.1
"composer/package-versions-deprecated": "^1.11", // 1.11.99
"friendsofsymfony/jsrouting-bundle": "^1.6" // 1.6.0
},
"require-dev": {
"sensio/generator-bundle": "^3.0", // v3.1.1
"symfony/phpunit-bridge": "^3.0" // v3.1.6
}
}
12 Comments
Hi, i'm trying to make the function in controller but symfony doesn't find the right class. How can i resolve?
Hey Alessandro,
This sounds like you have a different problem not related to the function you're going to create. Please, double check your syntax, usually PhpStorm gives you hints about syntax errors and show the affected line. If you still need help - please, share the exact error, otherwise it's difficult to guess what's the problem exactly :)
Cheers!
Here is your problem
So glad about this excellent class!
I'd like to know how to solve this problem when clicking on the item to be deleted.
"DELETE http://127.0.0.1:8000/deleteUrl 404 (Not Found)"
Hey Yurniel L.
How did you generate the delete URL? You are hitting
/deleteUrlinstead of/reps/{ID-of-the-rep}Cheers!
Magnificent class!
Hi Ryan,
I have a little question about Symfony ;)
In delete method you have a method denyAccessUnlessGranted, I know this is a new method since sf 2.8 or 2.7 but I didn't know that you can pass 'IS_AUTHENTICATED_REMEMBER'.
Could you explain me a little this?
Thanks
Cheers
Greg
Hey Greg!
Sure thing :). So, denyAccessUnlessGranted - and really, any way that you check security, including
is_grantedin Twig and even therolesyou list for eachaccess_controlin security.yml - they all, ultimately call theisGranted()method on thesecurity.authorization_checkerservice (this service was calledsecurity.contextbefore 2.8). In other words, whatever you can pass todenyAccessUnlessGrantedis the same thing you can pass in any of these other situations.Now, at first, the security system really only supports passing one type of thing to these functions: roles (e.g. anything starting with
ROLE_). I'm guessing that makes good sense to you :). But, the security system also supports passing three other special things:IS_AUTHENTICATED_ANONYMOUSLY,IS_AUTHENTICATED_REMEMBEREDandIS_AUTHENTICATED_FULLY. These strings correspond to the level of authentication of the user - e.g. "are they logged in?" or "are they logged in via a remember me cookie only?". We actually explain this best in an older Symfony 2 tutorial: https://knpuniversity.com/screencast/symfony2-ep2/twig-security-is-authenticated.So, that's the basic answer: all security functions ultimately call the same core function, and that function supports ROLE_ stuff and these 3 ISAUTHENTICATED items as well. But, to go deeper, the real answer is voters :). https://knpuniversity.com/screencast/new-in-symfony3/voter. Symfony's core comes with 2 (this is not 100% true, but just pretend it is) voters: one that handles ROLE_ items and one that handles ISAUTHENTICATED. So actually, you can pass ANYTHING you want to
denyAccessUnlessGranted(or the other functions), as long as you create a new voter that can handle that string.That was probably more info than you wanted - I hope some of it was what you were looking for :).
Cheers!
Hello Ryan,
so I assume that in this case I have to write a special Voter so that nobody else than the creator himself can delete his own RepRow post?
Otherwhise, even with IS_AUTHENTICATED_REMEMBERED everybody else, who is logged in can delete his post?Am I right?
Thank you :)
Hey Chris!
That's correct, you need to write your own Voter that checks if the user is the owner of that post. Checking for "IS_AUTHENTICATED_***" only tells you if the user is logged in via a form, cookie or anonymous
Have a nice day :)
"Before the AJAX call - that's important, we'll find out why soon - find the total weight container by saying $table.find('.js-total-weight')"
Sorry but I haven't found a reason behind this. Shame on me :)
Yo Ivan!
Hahaha - actually, this is our fault! When I originally wrote the code for this line, I was using
this. And so, putting it before the AJAX callback was important - sincethisis replaced. But, with the final code, we're not usingthis, so it is actually not important where this code lives. My mistake for not catching that! Thanks for bringing it up!Cheers!
"Houston: no signs of life"
Start the conversation!