DEV: Rename custom getOwner to getOwnerWithFallback (#23437)

Our custom implementation of `getOwner` includes a fallback which returns an owner, even if the passed object does not have one set. This is confusing and creates a false sense of security. Generally if the fallback is used, it means there is a problem with the patterns being used.

This commit renames our custom implementation to `getOwnerWithFallback`, while maintaining the old `getOwner` export with a deprecation notice. Core code is updated to use the official `@ember/application` implementation, or the new `getOwnerWithFallback` function.

This commit updates all core uses of `{ getOwner } from discourse-common/lib/get-owner` to use `getOwnerWithFallback`. Future commits will work through and convert many of these to use the official `@ember/application` implementation
This commit is contained in:
David Taylor
2023-09-26 14:30:52 +01:00
committed by GitHub
parent 2e950eb07a
commit 8958b4f76a
99 changed files with 487 additions and 381 deletions

View File

@@ -5,7 +5,7 @@ import { inject as service } from "@ember/service";
import DButton from "discourse/components/d-button";
import DFloatBody from "float-kit/components/d-float-body";
import concatClass from "discourse/helpers/concat-class";
import { getOwner } from "discourse-common/lib/get-owner";
import { getOwner } from "@ember/application";
import DMenuInstance from "float-kit/lib/d-menu-instance";
export default class DMenu extends Component {