Jet\Application_Modules
As you already know, this class is used for working with modules. Let's see what it can do.
Overview of methods
Method | Meaning of |
---|---|
public static getHandler( ): Application_Modules_Handler |
It probably won't surprise you anymore that the class doesn't perform operations with modules directly, but uses a handler (i.e. a backend) that actually performs operations like loading manifests and working with files containing module lists. So again, this class is just a facade and a container. And yes, even working with modules is actually modular itself. You can make your own handler. Just create a class inheriting from the abstract class Jet\Application_Modules_Handler. However, if you don't set up a custom handler, then Jet\Application_Modules_Handler_Default is used. |
public static setHandler( Application_Modules_Handler $handler ):void |
Sets the handler instance. See the getHandler method. It is not normally necessary to call this method. The system uses the default handler by default. That is, you call this method only if you wish to use a custom handler (and it is not sufficient to change the default handler class name using factory) and only during the application initialization phase. |
public static getModuleDir( string $module_name ): string |
Returns the full path to the module directory of the given name. |
public static allModulesList( ): Application_Module_Manifest[] |
Returns an array of manifests of all modules found, regardless of whether they are installed and active. |
public static installedModulesList( ): Application_Module_Manifest[] |
Returns an array of manifests of all installed modules, even if they are not active. |
public static activatedModulesList( ): Application_Module_Manifest[] |
Returns an array of manifests of all installed and activated modules. |
public static moduleExists( string $module_name ): bool |
Indicates whether the module exists at all, regardless of whether it is installed and active. |
public static moduleIsInstalled( string $module_name ): bool |
Indicates whether the module is installed regardless of whether it is active. |
public static moduleIsActivated( string $module_name ): bool |
Indicates whether the module is installed and active. |
public static moduleManifest( string $module_name ): Application_Module_Manifest |
Returns a manifest of the specified module. Beware! The requested module must exist (but need not be installed and active). |
public static installModule( string $module_name ): void |
It installs the module and executes the installation script (if any) during installation. If anything fails, it throws a Jet\Application_Modules_Exception exception. |
public static uninstallModule( string $module_name ): void |
Uninstalls the module and executes the uninstall script (if any) during the uninstall. If anything fails, it throws a Jet\Application_Modules_Exception exception. |
public static activateModule( string $module_name ): void |
Activates the module. If anything fails, it throws the Jet\Application_Modules_Exception exception. |
public static deactivateModule( string $module_name ): void |
Deactivates the module. If anything fails, it throws a Jet\Application_Modules_Exception. |
public static moduleInstance( string $module_name ): Application_Module |
Returns an instance of the Main class of the requested module. The module must be active. If it is not, then the Jet\Application_Modules_Exception exception is thrown. This should not happen in the application. Before working with the module, it is advisable to check its availability and solve the application logic accordingly. Or the module should be mandated and it should be ensured that nobody deactivates it. |
public static readManifestData( string $module_name ): void |
Retrieves the raw data from the manifest file. |
public static saveManifest( Application_Module_Manifest $manifest ): void |
Writes the manifest data to a file. |