Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
| en:entwickler:plugin_manager [2026/02/01 16:58] – [Naming conventions] mightymcoder | en:entwickler:plugin_manager [2026/02/08 12:14] (current) – [Singleton / Basic Handling] mightymcoder | ||
|---|---|---|---|
| Line 9: | Line 9: | ||
| plugins in Admidio. | plugins in Admidio. | ||
| + | With the Plugin Manager it is now also possible to easily and quickly integrate your own custom overview plugins. | ||
| + | |||
| + | A Basic //" | ||
| ======== Make your plugin compatible with the Plugin Manager (Admidio 5) ======== | ======== Make your plugin compatible with the Plugin Manager (Admidio 5) ======== | ||
| To make your plugin compatible with the Plugin Manager certain requirements must first be met. These include: | To make your plugin compatible with the Plugin Manager certain requirements must first be met. These include: | ||
| * [[en: | * [[en: | ||
| * A consistent [[en: | * A consistent [[en: | ||
| - | * A [[en: | ||
| - | * A [[en: | ||
| * A JSON [[en: | * A JSON [[en: | ||
| + | * A [[en: | ||
| + | * A [[en: | ||
| ======= Naming conventions ======= | ======= Naming conventions ======= | ||
| - | To use the new Plugin Manager | + | When using the new Plugin Manager, the following |
| - | - For better readability file and folder names containing multiple words should follow | + | - For better readability file and folder names containing multiple words should follow |
| - | - All folder and file names containing multiple words and are placed inside the //classes// folder should follow UpperCamelCase (PascalCase) notation. | + | - All folder and file names containing multiple words and are placed inside the //classes// folder should follow |
| - No plugin file defining a class may contain delimiters such as //" | - No plugin file defining a class may contain delimiters such as //" | ||
| ======= Folder structure ======= | ======= Folder structure ======= | ||
| Line 27: | Line 30: | ||
| ====== classes folder ====== | ====== classes folder ====== | ||
| + | ===== Main plugin class ===== | ||
| + | The main [[en: | ||
| + | |||
| ===== Presenter classes ===== | ===== Presenter classes ===== | ||
| ==== Plugin-specific classes ==== | ==== Plugin-specific classes ==== | ||
| Line 240: | Line 246: | ||
| ===== Entity, Service and ValueObjects classes ===== | ===== Entity, Service and ValueObjects classes ===== | ||
| If the plugin has specific //Entity//, // | If the plugin has specific //Entity//, // | ||
| - | |||
| - | ===== Main plugin class ===== | ||
| - | The main [[en: | ||
| ====== db_scripts folder ====== | ====== db_scripts folder ====== | ||
| Line 532: | Line 535: | ||
| The //Plugin// class extends the basic functionality provided by the abstract class // | The //Plugin// class extends the basic functionality provided by the abstract class // | ||
| - | In its simplest implementation | + | If there is nothing to render |
| <code php> | <code php> | ||
| - | public static function doRender(?PagePresenter | + | namespace Birthday\classes; |
| + | |||
| + | use Admidio\Infrastructure\Plugins\PluginAbstract; | ||
| + | use Admidio\UI\Presenter\PagePresenter; | ||
| + | |||
| + | class Birthday extends PluginAbstract | ||
| { | { | ||
| - | | + | |
| - | | + | |
| + | | ||
| } | } | ||
| - | $page->show(); | + | } |
| + | </code> | ||
| - | | + | In its simplest implementation for displaying something the // |
| + | <code php> | ||
| + | namespace Birthday\classes; | ||
| + | |||
| + | use Admidio\Infrastructure\Plugins\PluginAbstract; | ||
| + | use Admidio\UI\Presenter\PagePresenter; | ||
| + | |||
| + | class Birthday extends PluginAbstract | ||
| + | { | ||
| + | public static function doRender(? | ||
| + | { | ||
| + | if (!isset($page)) { | ||
| + | throw new Exception(" | ||
| + | } | ||
| + | $page-> | ||
| + | |||
| + | | ||
| + | } | ||
| } | } | ||
| </ | </ | ||
| Line 571: | Line 598: | ||
| methods documentation | methods documentation | ||
| </ | </ | ||
| + | |||
| + | The // | ||
| + | |||
| + | Provides: | ||
| + | * installation / uninstallation | ||
| + | * updates | ||
| + | * configuration handling | ||
| + | * dependency checks | ||
| + | * autoload registration | ||
| + | * visibility + activation control | ||
| + | |||
| + | All custom plugins should extend this class. | ||
| + | |||
| + | ----- | ||
| + | |||
| + | ===== Singleton / Basic Handling ===== | ||
| + | ^ Method ^ Description ^ Return ^ | ||
| + | | getInstance() | Returns the singleton instance of the plugin class | PluginAbstract | | ||
| + | | < | ||
| + | | < | ||
| + | | < | ||
| + | |||
| + | ----- | ||
| + | |||
| + | ===== Menu Integration / Preferences ===== | ||
| + | ^ Method ^ Description ^ Return ^ | ||
| + | | addMenuEntry() | Adds the plugin menu entry to the database | void | | ||
| + | | removeMenuEntry() | Removes the plugin menu entry from the database | void | | ||
| + | | initPreferencePanelCallback() | Initializes plugin preference panel integration | void | | ||
| + | |||
| + | ----- | ||
| + | |||
| + | ===== Metadata / Identity ===== | ||
| + | ^ Method ^ Description ^ Return ^ | ||
| + | | getName() | Returns the plugin name | string | | ||
| + | | getIcon() | Returns the plugin icon from metadata | string | | ||
| + | | getVersion() | Returns the plugin version | string | | ||
| + | | getMetadata() | Returns the complete metadata definition | array | | ||
| + | | getDependencies() | Returns declared dependencies | array | | ||
| + | | getSupportedLanguages() | Returns supported languages | array | | ||
| + | |||
| + | ----- | ||
| + | |||
| + | ===== Static Files ===== | ||
| + | ^ Method ^ Description ^ Return ^ | ||
| + | | getStaticFiles(? | ||
| + | |||
| + | Example: | ||
| + | <code php> | ||
| + | Plugin:: | ||
| + | </ | ||
| + | |||
| + | ----- | ||
| + | |||
| + | ===== Configuration & Component Information ===== | ||
| + | ^ Method ^ Description ^ Return ^ | ||
| + | | getPluginConfigValues() | Returns stored config values only (key => value) | array | | ||
| + | | getPluginConfig() | Returns merged configuration (defaults + DB) | array | | ||
| + | | getPluginPath() | Absolute filesystem path | string | | ||
| + | | getComponentId() | Database component ID | int | | ||
| + | | getComponentName() | Plugin folder name | string | | ||
| + | | getPluginSequence() | Overview sorting sequence | int | | ||
| + | |||
| + | ----- | ||
| + | |||
| + | ===== Dependency Handling ===== | ||
| + | ^ Method ^ Description ^ Return ^ | ||
| + | | checkDependencies() | Verifies all dependencies are available | bool | | ||
| + | |||
| + | Internal helper: | ||
| + | <code php> | ||
| + | private static function findAdmidioClass(string $shortName): | ||
| + | </ | ||
| + | |||
| + | ----- | ||
| + | |||
| + | ===== Installation State / Visibility ===== | ||
| + | ^ Method ^ Description ^ Return ^ | ||
| + | | isInstalled() | Plugin exists in database | bool | | ||
| + | | isActivated() | Installed and activated | bool | | ||
| + | | isVisible() | Visible depending on config and login state | bool | | ||
| + | | isOverviewPlugin() | Registered as overview plugin | bool | | ||
| + | | isAdmidioPlugin() | Built-in overview plugin | bool | | ||
| + | | isUpdateAvailable() | Installed version differs from metadata | bool | | ||
| + | |||
| + | ----- | ||
| + | |||
| + | ===== Autoloading ===== | ||
| + | ^ Method ^ Description ^ Return ^ | ||
| + | | doClassAutoload(string $class) | Registers PSR-4 autoload mappings | bool | | ||
| + | |||
| + | Example metadata: | ||
| + | <code json> | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | } | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | ----- | ||
| + | |||
| + | ===== Lifecycle Methods ===== | ||
| + | |||
| + | ==== doInstall(bool $addMenuEntry = true) ==== | ||
| + | Installs the plugin. | ||
| + | |||
| + | Steps: | ||
| + | * store default config values | ||
| + | * execute install SQL scripts | ||
| + | * register component | ||
| + | * run update steps | ||
| + | * set version | ||
| + | * optionally create menu entry | ||
| + | |||
| + | Returns: bool | ||
| + | |||
| + | ---- | ||
| + | |||
| + | ==== doUninstall(bool $removeMenuEntry = true, array $options = array()) ==== | ||
| + | Removes the plugin completely. | ||
| + | |||
| + | Steps: | ||
| + | * execute uninstall SQL scripts | ||
| + | * delete config values | ||
| + | * remove menu entries | ||
| + | * delete component | ||
| + | * reset version | ||
| + | |||
| + | Returns: bool | ||
| + | |||
| + | ---- | ||
| + | |||
| + | ==== doUpdate() ==== | ||
| + | Updates an installed plugin. | ||
| + | |||
| + | Steps: | ||
| + | * add missing config defaults | ||
| + | * run update classes | ||
| + | * update stored version | ||
| + | |||
| + | Returns: bool | ||
| + | |||
| + | ---- | ||
| + | |||
| + | ==== initParams(array $params = array()) ==== | ||
| + | Optional initialization hook for plugins. | ||
| + | |||
| + | Returns: bool | ||
| + | |||
| + | ----- | ||
| + | |||
| + | ===== Internal Helpers (private) ===== | ||
| + | ^ Method ^ Description ^ | ||
| + | | readPluginMetadata() | Loads and parses metadata file | | ||
| + | | getClassNameFromFile(string $file) | Extracts class name from PHP file | | ||
| + | | toggleForeignKeyChecks(bool $enable) | Enables/ | ||
| + | |||