Пример #1
0
 /**
  * Get Components info action
  *
  * @return \Zend\View\Model\JsonModel
  * @throws \RuntimeException
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 public function componentsAction()
 {
     $lastSyncData = $this->updatePackagesCache->getPackagesForUpdate();
     $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']) && $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'] = $this->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];
     }
     $packagesForInstall = $this->connectManager->getPackagesForInstall();
     $lastSyncData['countOfInstall'] = isset($packagesForInstall['packages']) ? count($packagesForInstall['packages']) : 0;
     $lastSyncData['countOfUpdate'] = isset($lastSyncData['packages']) ? count($lastSyncData['packages']) : 0;
     return new \Zend\View\Model\JsonModel(['success' => true, 'components' => array_values($components), 'total' => count($components), 'lastSyncData' => $lastSyncData]);
 }
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $sampleDataPackages = $this->sampleDataDependency->getSampleDataPackages();
     if (!empty($sampleDataPackages)) {
         foreach (array_keys($sampleDataPackages) as $name) {
             $moduleName = $this->packageInfo->getModuleName($name);
             $this->moduleResource->setDataVersion($moduleName, '');
         }
         $output->writeln('<info>' . 'Reset of sample data version completed successfully.' . '</info>');
     } else {
         $output->writeln('<info>' . 'There is no sample data for current set of modules.' . '</info>');
     }
 }
Пример #3
0
 public function testGetModuleName()
 {
     $this->assertEquals('A', $this->packageInfo->getModuleName('a'));
     $this->assertEquals('B', $this->packageInfo->getModuleName('b'));
     $this->assertEquals('C', $this->packageInfo->getModuleName('c'));
     $this->assertEquals('D', $this->packageInfo->getModuleName('d'));
     $this->assertEquals('E', $this->packageInfo->getModuleName('e'));
     $this->assertEquals('Magento_TestModuleName', $this->packageInfo->getModuleName('magento/module-test-module-name'));
     $this->assertArrayHasKey('Magento_TestModuleName', $this->packageInfo->getNonExistingDependencies());
 }
Пример #4
0
 public function testGetModuleName()
 {
     $this->assertEquals('A', $this->packageInfo->getModuleName('a'));
     $this->assertEquals('B', $this->packageInfo->getModuleName('b'));
     $this->assertEquals('C', $this->packageInfo->getModuleName('c'));
     $this->assertEquals('D', $this->packageInfo->getModuleName('d'));
     $this->assertEquals('E', $this->packageInfo->getModuleName('e'));
 }
Пример #5
0
 /**
  * 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]);
 }