Software: Apache/2.4.41 (Ubuntu). PHP/8.0.30 uname -a: Linux apirnd 5.4.0-204-generic #224-Ubuntu SMP Thu Dec 5 13:38:28 UTC 2024 x86_64 uid=33(www-data) gid=33(www-data) groups=33(www-data) Safe-mode: OFF (not secure) /var/www/html/wincloud_gateway/node_modules/strapi-admin/domain/action/ drwxr-xr-x | |
| Viewing file: Select action/file-type: 'use strict';
const { providerFactory, hooks } = require('strapi-utils');
const { validateRegisterProviderAction } = require('../../validation/action-provider');
const domain = require('./index');
/**
* @typedef ActionProviderOverride
* @property {function(CreateActionPayload)} register
* @property {function(attributes CreateActionPayload[]): Promise<this>} registerMany
*/
/**
* Creates a new instance of an action provider
* @return {Provider & ActionProviderOverride}
*/
const createActionProvider = options => {
const provider = providerFactory(options);
const actionHooks = {
appliesPropertyToSubject: hooks.createAsyncParallelHook(),
};
return {
...provider,
hooks: {
...provider.hooks,
...actionHooks,
},
async register(actionAttributes) {
if (strapi.isLoaded) {
throw new Error(`You can't register new actions outside of the bootstrap function.`);
}
validateRegisterProviderAction([actionAttributes]);
const action = domain.create(actionAttributes);
return provider.register(action.actionId, action);
},
async registerMany(actionsAttributes) {
validateRegisterProviderAction(actionsAttributes);
for (const attributes of actionsAttributes) {
await this.register(attributes);
}
return this;
},
async appliesToProperty(property, actionId, subject) {
const action = provider.get(actionId);
const appliesToAction = domain.appliesToProperty(property, action);
// If the property isn't valid for this action, ignore the rest of the checks
if (!appliesToAction) {
return false;
}
// If the property is valid for this action and there isn't any subject
if (!subject) {
return true;
}
// If the property is valid for this action and the subject is not handled by the action
if (!domain.appliesToSubject(subject, action)) {
return false;
}
const results = await actionHooks.appliesPropertyToSubject.call({
property,
action,
subject,
});
return results.every(result => result !== false);
},
};
};
module.exports = createActionProvider;
|
:: Command execute :: | |
--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0042 ]-- |