Context: How is the backend’s Component Manager grid rendered?
7e9d18/setup/src/Magento/Setup/Controller/ComponentGrid.php#L82-L140
/**
* Get Components info action
*
* @return \Zend\View\Model\JsonModel
* @throws \RuntimeException
*/
public function componentsAction()
{
$objectManager = $this->objectManagerProvider->get();
$enabledModuleList = $objectManager->get('Magento\Framework\Module\ModuleList');
$this->fullModuleList = $objectManager->get('Magento\Framework\Module\FullModuleList');
$this->packageInfo = $objectManager->get('Magento\Framework\Module\PackageInfoFactory')->create();
$lastSyncData = [];
$authDetails = $this->packagesAuth->getAuthJsonData();
if ($authDetails) {
$lastSyncData = $this->packagesData->syncPackagesData();
}
$components = $this->composerInformation->getInstalledMagentoPackages();
$allModules = $this->getAllModules();
$components = array_replace_recursive($components, $allModules);
foreach ($components as $component) {
$components[$component['name']]['update'] = false;
$components[$component['name']]['uninstall'] = false;
$components[$component['name']]['moduleName'] = $this->packageInfo->getModuleName($component['name']);
if ($this->composerInformation->isPackageInComposerJson($component['name'])) {
if ($component['type'] !== \Magento\Framework\Composer\ComposerInformation::METAPACKAGE_PACKAGE_TYPE) {
$components[$component['name']]['uninstall'] = true;
}
if (isset($lastSyncData['packages'][$component['name']]['latestVersion'])
&& version_compare(
$lastSyncData['packages'][$component['name']]['latestVersion'],
$component['version'],
'>'
)) {
$components[$component['name']]['update'] = true;
}
}
if ($component['type'] === \Magento\Framework\Composer\ComposerInformation::MODULE_PACKAGE_TYPE) {
$components[$component['name']]['enable'] =
$enabledModuleList->has($components[$component['name']]['moduleName']);
$components[$component['name']]['disable'] = !$components[$component['name']]['enable'];
} else {
$components[$component['name']]['enable'] = false;
$components[$component['name']]['disable'] = false;
}
$componentNameParts = explode('/', $component['name']);
$components[$component['name']]['vendor'] = $componentNameParts[0];
}
return new \Zend\View\Model\JsonModel(
[
'success' => true,
'components' => array_values($components),
'total' => count($components),
'lastSyncData' => $lastSyncData
]
);
}