productMetadata = $productMetadata; parent::__construct($context); } /** * Sets the response body to ProductName/Major.MinorVersion (Edition). E.g.: Magento/0.42 (Community). Omits patch * version from response * * @return void */ public function execute() { $version = $this->productMetadata->getVersion(); $versionParts = explode('.', $version); if ((!isset($versionParts[0]) || !isset($versionParts[1])) || $this->isGitBasedInstallation($version) ) { return; } $majorMinorVersion = $versionParts[0] . '.' . $versionParts[1]; $this->getResponse()->setBody( $this->productMetadata->getName() . '/' . $majorMinorVersion . ' (' . $this->productMetadata->getEdition() . ')' ); } /** * Check if provided version is generated by Git-based Magento instance. * * @param string $fullVersion * @return bool */ private function isGitBasedInstallation($fullVersion) { $versionParts = explode('-', $fullVersion); return (isset($versionParts[0]) && $versionParts[0] == 'dev'); } }