user->getIdentity(); if ($identity === null) { return false; } $account = $identity->getAccount(); if ($account === null) { return false; } if ($account->id !== (int)$accountId) { return false; } $allowDeleted = $params['allowDeleted'] ?? false; if ($account->status !== Account::STATUS_ACTIVE // if deleted accounts are allowed, but the passed one is not in deleted state && (!$allowDeleted || $account->status !== Account::STATUS_DELETED) ) { return false; } $actualRulesOptional = $params['optionalRules'] ?? false; if (!$actualRulesOptional && !$account->isAgreedWithActualRules()) { return false; } return true; } }