Skip to content

Commit d985414

Browse files
committed
fix: add getPlugin(s)ByClassName to IAdminForth for TS types integrity
1 parent e62b1b8 commit d985414

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

adminforth/types/Back.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,27 @@ export interface IAdminForth {
370370
*/
371371
setupEndpoints(server: IHttpServer): void;
372372

373+
/**
374+
* This method can be used when you want to get some plugin instances by class name.
375+
* Should be used for plugins which might have multiple instances with the same class name.
376+
* @param className - name of class which is used to identify plugin instance
377+
*/
378+
getPluginsByClassName<T>(className: string): T[];
379+
380+
/**
381+
* This method can be used when you want to get some plugin instance by class name.
382+
* Should be called only if you are sure there is only one plugin instance with this class name.
383+
* If several instances are found, this method will drop error.
384+
* @param className - name of class which is used to identify plugin instance
385+
*
386+
* Example:
387+
*
388+
* ```ts
389+
* const i18nPlugin = adminforth.getPluginByClassName<I18nPlugin>('I18nPlugin');
390+
* ```
391+
*
392+
*/
393+
getPluginByClassName<T>(className: string): T;
373394
}
374395

375396

0 commit comments

Comments
 (0)