I have seen \Magento\Framework\Module\ModuleListInterface $moduleList implemented in a custom module like that

$this->_moduleList = $moduleList;
public function getExtensionVersion()
    $moduleCode = 'My_Module';
    $moduleInfo = $this->_moduleList->getOne($moduleCode);
    return $moduleInfo['setup_version'];

My question is, What is the purpose of this interface and which methods we can invoke using this interface?

1 Answer 1


The purpose this class is to get the information about modules. Use these methods using ModuleListInterface.

  namespace Magento\Framework\Module;
  interface ModuleListInterface
     public function getAll();
     public function getOne($name);
     public function getNames();
      public function has($name);

Documentation Link

  • what is getAll() for? and same like getOne,getNames,has
    – KamranKhan
    Mar 27, 2018 at 6:47
  • 1
    The methods do what their names suggest: getAll - retrieves you info about all installed modules, getOne - gets you info about a specific module, getNames gets you the names of the installed modules and has checks if a module exists without retrieving the info.
    – Marius
    Mar 27, 2018 at 6:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.