-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
/
build-owner.js
42 lines (33 loc) · 1.04 KB
/
build-owner.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import { Registry } from 'container';
import { Router } from 'ember-routing';
import {
Application,
ApplicationInstance
} from 'ember-application';
import {
RegistryProxyMixin,
ContainerProxyMixin,
Object as EmberObject
} from 'ember-runtime';
export default function buildOwner(options = {}) {
let ownerOptions = options.ownerOptions || {};
let resolver = options.resolver;
let bootOptions = options.bootOptions || {};
let Owner = EmberObject.extend(RegistryProxyMixin, ContainerProxyMixin);
let namespace = EmberObject.create({
Resolver: { create() { return resolver; } }
});
let fallbackRegistry = Application.buildRegistry(namespace);
fallbackRegistry.register('router:main', Router);
let registry = new Registry({
fallback: fallbackRegistry
});
ApplicationInstance.setupRegistry(registry, bootOptions);
let owner = Owner.create({
__registry__: registry,
__container__: null
}, ownerOptions);
let container = registry.container({ owner: owner });
owner.__container__ = container;
return owner;
}