2021-08-19 22:27:00 +02:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const _ = require('lodash');
|
|
|
|
|
2021-10-07 13:13:30 +02:00
|
|
|
// TODO: remove this tmp fix and migrate tests
|
2021-08-19 22:27:00 +02:00
|
|
|
let strapiInstance;
|
|
|
|
Object.defineProperty(global, 'strapi', {
|
|
|
|
get() {
|
|
|
|
return strapiInstance;
|
|
|
|
},
|
|
|
|
set(value) {
|
|
|
|
strapiInstance = value;
|
|
|
|
|
2022-08-08 23:33:39 +02:00
|
|
|
strapiInstance.plugin = (name) => strapiInstance.plugins[name];
|
|
|
|
_.mapValues(strapi.plugins, (plugin) => {
|
|
|
|
plugin.controller = (name) => plugin.controllers[name];
|
|
|
|
plugin.service = (name) => plugin.services[name];
|
|
|
|
plugin.contentType = (name) => plugin.contentTypes[name];
|
|
|
|
plugin.policy = (name) => plugin.policies[name];
|
2021-08-19 22:27:00 +02:00
|
|
|
});
|
2021-10-07 13:13:30 +02:00
|
|
|
|
2021-10-26 17:14:20 +02:00
|
|
|
strapiInstance.service = (name = '') => {
|
2021-10-07 13:13:30 +02:00
|
|
|
if (name.startsWith('admin::')) {
|
|
|
|
return strapiInstance.admin.services[name.split('admin::')[1]];
|
|
|
|
}
|
|
|
|
};
|
2021-08-19 22:27:00 +02:00
|
|
|
},
|
|
|
|
});
|