/** * Retrieves the version of an installed extension. * If the extension is not installed, this function returns an empty string. * * @param string $key The key of the extension to look up, must not be empty * * @throws \InvalidArgumentException * @throws \TYPO3\CMS\Core\Package\Exception * @return string The extension version as a string in the format "x.y.z", */ public static function getExtensionVersion($key) { if (!is_string($key) || empty($key)) { throw new \InvalidArgumentException('Extension key must be a non-empty string.', 1294586096); } if (!static::isLoaded($key)) { return ''; } $version = static::$packageManager->getPackage($key)->getPackageMetaData()->getVersion(); if (empty($version)) { throw new \TYPO3\CMS\Core\Package\Exception('Version number in composer manifest of package "' . $key . '" is missing or invalid', 1395614959); } return $version; }
/** * Get all class names inside this namespace and return them as array. * This has to be done by iterating over class files for TYPO3 CMS * as the Extbase Reflection Service cannot return all implementations * of Fluid AbstractViewHelpers * * @param string $namespace * @return array Array of all class names inside a given namespace. */ protected function getClassNamesInNamespace($namespace) { $packageKey = $this->getPackageKeyFromNamespace($namespace); $viewHelperClassFiles = GeneralUtility::getAllFilesAndFoldersInPath(array(), $this->packageManager->getPackage($packageKey)->getPackagePath() . 'Classes/ViewHelpers/', 'php'); $affectedViewHelperClassNames = array(); foreach ($viewHelperClassFiles as $filePathAndFilename) { $potentialViewHelperClassName = $this->getClassNameFromNamespaceAndPath($namespace, $filePathAndFilename); if (is_subclass_of($potentialViewHelperClassName, 'TYPO3\\CMS\\Fluid\\Core\\ViewHelper\\AbstractViewHelper')) { $classReflection = new \ReflectionClass($potentialViewHelperClassName); if ($classReflection->isAbstract() === TRUE) { continue; } $affectedViewHelperClassNames[] = $potentialViewHelperClassName; } } sort($affectedViewHelperClassNames); return $affectedViewHelperClassNames; }
/** * @test * @expectedException \TYPO3\CMS\Core\Package\Exception\UnknownPackageException */ public function getPackageThrowsExceptionOnUnknownPackage() { $this->packageManager->getPackage('PrettyUnlikelyThatThisPackageExists'); }
/** * @return \TYPO3\CMS\Core\Package\PackageInterface * @api */ public function getPackage() { return $this->packageManager->getPackage($this->extensionKey); }
/** * Asserts the expected differences are found */ protected function assertFixtureExtensionChangesAreFound() { $package = $this->packageManager->getPackage($this->fixtureExtensionKey); $repository = ExtensionInformationRepositoryFactory::create(); $this->assertSame($this->expectedDifferences, $repository->findDifferentExtensionInformation($package)); }