1 | import { deprecate } from '@ember/debug';
|
2 | import { DEBUG } from '@glimmer/env';
|
3 |
|
4 | import Store from '@ember-data/store';
|
5 |
|
6 | function initializeStore(application) {
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 | if (DEBUG && !application.registerOptionsForType) {
|
13 | deprecate(
|
14 | `Deprecated test syntax usage detected!\n\n\t` +
|
15 | `This test relies on a deprecated test setup that is no longer supported by EmberData.` +
|
16 | ` To resolve this you will need to be on a recent version of @ember/test-helpers` +
|
17 | ` AND your tests must use \`setApplication()\` instead of \`setResolver()\` and` +
|
18 | ` \`module()\` with \`setup*Test()\`instead of \`moduleFor*()\`.`,
|
19 | false,
|
20 | {
|
21 | id: 'ember-data:legacy-test-helper-support',
|
22 | until: '3.17',
|
23 | }
|
24 | );
|
25 |
|
26 | application.optionsForType('serializer', { singleton: false });
|
27 | application.optionsForType('adapter', { singleton: false });
|
28 |
|
29 | if (!application.has('service:store')) {
|
30 | application.register('service:store', Store);
|
31 | }
|
32 |
|
33 | return;
|
34 | }
|
35 |
|
36 | application.registerOptionsForType('serializer', { singleton: false });
|
37 | application.registerOptionsForType('adapter', { singleton: false });
|
38 |
|
39 | if (!application.hasRegistration('service:store')) {
|
40 | application.register('service:store', Store);
|
41 | }
|
42 | }
|
43 |
|
44 | function initializeStoreInjections(application) {
|
45 | let inject = application.inject || application.injection;
|
46 | inject.call(application, 'controller', 'store', 'service:store');
|
47 | inject.call(application, 'route', 'store', 'service:store');
|
48 | }
|
49 |
|
50 | export default function setupContainer(application) {
|
51 | initializeStoreInjections(application);
|
52 | initializeStore(application);
|
53 | }
|