1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-12 09:44:38 +02:00

Make $modules->isUninstallable() method hookable and update the $modules->isInstallable() method to detect when module doesn't implement required 'Module' interface.

This commit is contained in:
Ryan Cramer
2021-06-25 13:45:09 -04:00
parent bb6e7f79b8
commit 5e663ccf13

View File

@@ -37,6 +37,7 @@
* @method bool saveConfig($class, $data, $value = null) * @method bool saveConfig($class, $data, $value = null)
* @method InputfieldWrapper|null getModuleConfigInputfields($moduleName, InputfieldWrapper $form = null) #pw-internal * @method InputfieldWrapper|null getModuleConfigInputfields($moduleName, InputfieldWrapper $form = null) #pw-internal
* @method void moduleVersionChanged(Module $module, $fromVersion, $toVersion) #pw-internal * @method void moduleVersionChanged(Module $module, $fromVersion, $toVersion) #pw-internal
* @method bool|string isUninstallable($class, $returnReason = false) hookable in 3.0.181+ #pw-internal
* *
*/ */
@@ -1927,6 +1928,10 @@ class Modules extends WireArray {
public function isInstallable($class, $now = false) { public function isInstallable($class, $now = false) {
$installable = array_key_exists($class, $this->installable); $installable = array_key_exists($class, $this->installable);
if(!$installable) return false; if(!$installable) return false;
if(!wireInstanceOf($class, 'Module')) {
$nsClass = $this->getModuleClass($class, true);
if(!wireInstanceOf($nsClass, 'ProcessWire\\Module')) return false;
}
if($now) { if($now) {
$requires = $this->getRequiresForInstall($class); $requires = $this->getRequiresForInstall($class);
if(count($requires)) return false; if(count($requires)) return false;
@@ -2112,7 +2117,7 @@ class Modules extends WireArray {
* @return bool|string * @return bool|string
* *
*/ */
public function isUninstallable($class, $returnReason = false) { public function ___isUninstallable($class, $returnReason = false) {
$reason = ''; $reason = '';
$reason1 = $this->_("Module is not already installed"); $reason1 = $this->_("Module is not already installed");