Skip to content

Commit 0e678a9

Browse files
committed
Update register entity action
1 parent 6b7bc5d commit 0e678a9

File tree

1 file changed

+38
-3
lines changed

1 file changed

+38
-3
lines changed

16/umbraco-cms/customizing/extending-overview/extension-types/entity-actions.md

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,31 @@ Sidebar Context Menu is an entity action that can be performed on a menu item. F
5050

5151
## Registering an Entity Action <a href="#registering-an-entity-action" id="registering-an-entity-action"></a>
5252

53+
To register an Entity Action in Umbraco, you first need to create an `umbraco-package.json` file for your package. This file serves as the package manifest, allowing Umbraco to discover and register your extension.
54+
You can find detailed guidance on creating and configuring the package manifest here:
55+
[Umbraco Extension Registry Documentation](https://docs.umbraco.com/umbraco-cms/customizing/extending-overview/extension-registry/extension-registry)
56+
57+
**`umbraco-package.json`**
58+
```json
59+
{
60+
"$schema": "../../umbraco-package-schema.json",
61+
"name": "My entity action",
62+
"version": "1.0.0",
63+
"extensions": [
64+
{
65+
"type": "backofficeEntryPoint",
66+
"alias": "My.EntityAction.EntryPoint",
67+
"name": "My entity action EntryPoint",
68+
"js": "/App_Plugins/my-entity-action/my-entity-action.js"
69+
}
70+
]
71+
}
72+
```
73+
74+
**`my-entity-action.ts`**
5375
```typescript
54-
import { extensionRegistry } from '@umbraco-cms/extension-registry';
55-
import { MyEntityAction } from './entity-action';
76+
import type { UmbEntryPointOnInit } from '@umbraco-cms/backoffice/extension-api';
77+
import { MyEntityAction } from './entity-action.api.js';
5678

5779
const manifest = {
5880
type: 'entityAction',
@@ -67,8 +89,21 @@ const manifest = {
6789
repositoryAlias: 'My.Repository',
6890
},
6991
};
92+
export const onInit: UmbEntryPointOnInit = (_host, umbExtensionsRegistry) => {
93+
umbExtensionsRegistry.register(manifest); // Register the extension
94+
}
95+
```
7096

71-
extensionRegistry.register(manifest);
97+
**`my-entity-action.api.ts`**
98+
```typescript
99+
import { UmbEntityActionBase } from '@umbraco-cms/backoffice/entity-action';
100+
101+
export class MyEntityAction extends UmbEntityActionBase<any> {
102+
async execute() {
103+
//The execute() function is called when the user clicks on the custom Entity Action
104+
}
105+
}
106+
export { MyEntityAction as api };
72107
```
73108

74109
**Default Element**

0 commit comments

Comments
 (0)