amnah\yii2\user\components\User::can PHP Méthode

can() public méthode

If "authManager" component is set, this will simply use the default functionality. Otherwise, it will use our custom permission system
public can ( string $permissionName, array $params = [], boolean $allowCaching = true ) : boolean
$permissionName string
$params array
$allowCaching boolean
Résultat boolean
    public function can($permissionName, $params = [], $allowCaching = true)
    {
        // check for auth manager to call parent
        $auth = Yii::$app->getAuthManager();
        if ($auth) {
            return parent::can($permissionName, $params, $allowCaching);
        }
        // otherwise use our own custom permission (via the role table)
        /** @var \amnah\yii2\user\models\User $user */
        $user = $this->getIdentity();
        return $user ? $user->can($permissionName) : false;
    }