I made a module for Drupal 8.9
https://git.drupalcode.org/sandbox/zenimagine-3076032/-/tree/master
On my /user/ID/tasks page I have this error :
The website encountered an unexpected error. Please try again later. TypeError: Argument 1 passed to Drupal\Core\Access\AccessResult::allowedIfHasPermission() must implement interface Drupal\Core\Session\AccountInterface, string given, called in /var/www/www-example-com/web/modules/custom/task_notify/src/Controller/TaskNotifyUserController.php on line 19 in Drupal\Core\Access\AccessResult::allowedIfHasPermission() (line 116 of core/lib/Drupal/Core/Access/AccessResult.php).
What did I do wrong in my module ?
<?php
namespace Drupal\task_notify\Controller;
use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Access\AccessResult;
use Drupal\Core\Session\AccountInterface;
class TaskNotifyUserController extends ControllerBase {
public function Tasks() {
return [
'#theme' => 'task_notify_user_template',
];
}
public function taskAccess(AccountInterface $account) {
return AccessResult::allowedIf($account->id() == $this->currentUser()->id())
->orIf(AccessResult::allowedIfHasPermission('administer users'));
}
}
$accountobject inAccessResult::allowedIfHasPermission($account, 'administer users')- baikho