- Issue created by @tunic
- Assigned to shiv_yadav
- Issue was unassigned.
- 🇪🇸Spain tunic Madrid
Thanks for working on this!
+++ b/src/Form/NodeAuthlinkNodeForm.php @@ -182,7 +182,7 @@ class NodeAuthlinkNodeForm extends FormBase { - if (isset($enable[$node_instance->bundle()]) && $enable[$node_instance->bundle()] && ($account->hasPermission('create and delete node authlinks') || $account->hasPermission(sprintf('create and delete node %s authlinks', $node_instance->bundle())))) {
I think we should use dependency injector, so the permission checker service should be injected in the form class.
See https://www.drupal.org/docs/drupal-apis/services-and-dependency-injectio... →
- 🇮🇳India mukhtarm
@tunic Checked in D11 core modules and it still uses
$account->hasPermission
in many places.As per this https://www.drupal.org/node/3348054 → , Its introduced in
10.2.0
. I checked in D11 core modules and it uses$account->hasPermission
in many places instead of DI. Not sure how to accomplish this.Eg:
core/modules/book/book.module
,core/modules/content_translation/content_translation.module
etc.. - 🇪🇸Spain tunic Madrid
Yes, this new service is pretty new, there's a lot of places to update. It is not something really needed here, but I thought it was a nice novice task.
When you say "Not sure how to accomplish this" you mean injecting the service in the form class? You have to edit the create and __construct methods of the class NodeAuthlinkNodeForm. See for example how the entity_type.manager service is injected.
- Status changed to Needs work
over 1 year ago 2:42pm 26 October 2023