Closed apeisa closed 9 years ago
Looks like the InputfieldPageListSelect modules are calling ProcessPageList in their init() method, when they should instead do it in their render() method. I have fixed that locally and it'll be in this weeks commits. Thanks.
Depending on the scenario, it's not great to use $modules->find()
, especially for something like Inputfield or Process modules, because it instantiates all the modules it returns. It's better to iterate $modules directly, because any modules that aren't already loaded will be ModulePlaceholder classes, which don't consume any overhead, load other modules, or populate styles/scripts, etc. So in your case you'd want to do this, to list out all Inputfield modules, for example:
foreach($modules as $module) {
if(strpos($module->className(), 'Inputfield') === 0) {
echo "<li>" . $module->className() . "</li>";
}
}
Also, this is good timing because just last week I added a new method to $modules that probably suits your needs well:
foreach($modules->findByPrefix('Inputfield') as $name) {
echo $name;
}
It returns an array of strings of module class names, unless you specify a second argument of true, in which case it returns instantiated modules (which you probably don't want).
Thanks Ryan, findByPrefix works great!
It seems I cannot do simple find for modules. I am trying to list all inputfields there are available, but this code throws errors for all other's but superuser:
The error I get is this:
So it seems that InputfieldPageListSelect loads the ProcessPageList module, which has page-edit permission set.
In this case I think it's fine to whitelist/blacklist inputfields I am looking, but I find it little problematic, that simple find for modules can throw an exception.