mirror of
https://github.com/processwire/processwire.git
synced 2025-08-13 18:24:57 +02:00
Make $modules->getModule($moduleName) be non-case-sensitive for $moduleName. Plus minor updates to Fieldtypes API var and ProcessTemplate module.
This commit is contained in:
@@ -93,11 +93,8 @@ class Fieldtypes extends WireArray {
|
||||
*/
|
||||
public function init() {
|
||||
$this->isAPI = true;
|
||||
foreach($this->wire('modules') as $name => $module) {
|
||||
if(strpos($name, 'Fieldtype') === 0) {
|
||||
// if($module instanceof ModulePlaceholder) $module = $this->wire('modules')->get($module->className());
|
||||
$this->add($module);
|
||||
}
|
||||
foreach($this->wire()->modules->findByPrefix('Fieldtype', 3) as $name => $module) {
|
||||
$this->add($module);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,7 +110,7 @@ class Fieldtypes extends WireArray {
|
||||
foreach($this->data as $moduleName => $module) {
|
||||
if($module instanceof ModulePlaceholder) {
|
||||
$fieldtype = $modules->getModule($moduleName);
|
||||
$this->data[$moduleName] = $fieldtype;
|
||||
if($fieldtype) $this->data[$moduleName] = $fieldtype;
|
||||
}
|
||||
}
|
||||
if($debug) Debug::saveTimer('Fieldtypes.preload');
|
||||
@@ -188,10 +185,12 @@ class Fieldtypes extends WireArray {
|
||||
*/
|
||||
public function get($key) {
|
||||
|
||||
if(strpos($key, 'Fieldtype') !== 0) $key = "Fieldtype" . ucfirst($key);
|
||||
if(stripos($key, 'Fieldtype') !== 0) $key = 'Fieldtype' . ucfirst($key);
|
||||
|
||||
if(!$fieldtype = parent::get($key)) {
|
||||
$fieldtype = $this->wire()->modules->getModule($key);
|
||||
$fieldtype = parent::get($key);
|
||||
|
||||
if(!$fieldtype) {
|
||||
$fieldtype = $this->wire()->modules->getModule($key);
|
||||
if($fieldtype) $this->set($key, $fieldtype);
|
||||
}
|
||||
|
||||
|
@@ -1276,11 +1276,22 @@ class Modules extends WireArray {
|
||||
return empty($options['returnError']) ? null : "Unable to find module ID $moduleID";
|
||||
}
|
||||
} else {
|
||||
$moduleID = 0;
|
||||
$key = wireClassName($key, false);
|
||||
}
|
||||
|
||||
$module = parent::get($key);
|
||||
|
||||
if(!$module && !$moduleID) {
|
||||
// make non case-sensitive for module name ($key)
|
||||
$lowerKey = strtolower($key);
|
||||
foreach(array_keys($this->moduleIDs) as $className) {
|
||||
if(strtolower($className) !== $lowerKey) continue;
|
||||
$module = parent::get($className);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(!$module) {
|
||||
if(empty($options['noSubstitute'])) {
|
||||
if($this->isInstallable($key) && empty($options['noInstall'])) {
|
||||
|
Reference in New Issue
Block a user