public function load($modelId, $field = null) { parent::load($modelId, $field); $this->setId($modelId); // array_filter to remove empty items caused by non-magento modules requirements $this->setDepends(array_filter($this->packageInfo->getRequire($this->getCode()))); $this->setVersion($this->packageInfo->getVersion($this->getCode())); $this->setPackageName($this->packageInfo->getPackageName($this->getCode())); return $this; }
public function testGetVersion() { $this->assertEquals('0.1', $this->packageInfo->getVersion('A')); $this->assertEquals('0.2', $this->packageInfo->getVersion('B')); $this->assertEquals('0.1', $this->packageInfo->getVersion('C')); $this->assertEquals('0.3', $this->packageInfo->getVersion('D')); $this->assertEquals('0.4', $this->packageInfo->getVersion('E')); $this->assertEquals('', $this->packageInfo->getVersion('F')); }
/** * Get full list of modules as an associative array * * @return array */ private function getAllModules() { $modules = []; $allModules = $this->fullModuleList->getNames(); foreach ($allModules as $module) { $moduleName = $this->packageInfo->getPackageName($module); $modules[$moduleName]['name'] = $moduleName; $modules[$moduleName]['type'] = \Magento\Framework\Composer\ComposerInformation::MODULE_PACKAGE_TYPE; $modules[$moduleName]['version'] = $this->packageInfo->getVersion($module); } return $modules; }
/** * Check if two modules are conflicted and get the message for display * * @param string $moduleA * @param string $moduleB * @return string[] */ private function getConflictMessages($moduleA, $moduleB) { $messages = []; $versionParser = new VersionParser(); if (isset($this->packageInfo->getConflict($moduleB)[$moduleA]) && $this->packageInfo->getConflict($moduleB)[$moduleA] && $this->packageInfo->getVersion($moduleA)) { $constraintA = $versionParser->parseConstraints($this->packageInfo->getConflict($moduleB)[$moduleA]); $constraintB = $versionParser->parseConstraints($this->packageInfo->getVersion($moduleA)); if ($constraintA->matches($constraintB)) { $messages[] = "{$moduleB} conflicts with current {$moduleA} version " . $this->packageInfo->getVersion($moduleA) . ' (version should not be ' . $this->packageInfo->getConflict($moduleB)[$moduleA] . ')'; } } if (isset($this->packageInfo->getConflict($moduleA)[$moduleB]) && $this->packageInfo->getConflict($moduleA)[$moduleB] && $this->packageInfo->getVersion($moduleB)) { $constraintA = $versionParser->parseConstraints($this->packageInfo->getConflict($moduleA)[$moduleB]); $constraintB = $versionParser->parseConstraints($this->packageInfo->getVersion($moduleB)); if ($constraintA->matches($constraintB)) { $messages[] = "{$moduleA} conflicts with current {$moduleB} version " . $this->packageInfo->getVersion($moduleA) . ' (version should not be ' . $this->packageInfo->getConflict($moduleA)[$moduleB] . ')'; } } return $messages; }