/** * Register a native Flow package * * @param PackageInterface $package The Package to be registered * @param boolean $sortAndSave allows for not saving packagestates when used in loops etc. * @return PackageInterface * @throws Exception\InvalidPackageStateException */ public function registerPackage(PackageInterface $package, $sortAndSave = true) { $packageKey = $package->getPackageKey(); $caseSensitivePackageKey = $this->getCaseSensitivePackageKey($packageKey); if ($this->isPackageAvailable($caseSensitivePackageKey)) { throw new Exception\InvalidPackageStateException('Package "' . $packageKey . '" is already registered as "' . $caseSensitivePackageKey . '".', 1338996122); } $this->packages[$packageKey] = $package; $this->packageStatesConfiguration['packages'][$packageKey]['packagePath'] = str_replace($this->packagesBasePath, '', $package->getPackagePath()); $this->packageStatesConfiguration['packages'][$packageKey]['classesPath'] = str_replace($package->getPackagePath(), '', $package->getClassesPath()); if ($sortAndSave === true) { $this->sortAndSavePackageStates(); } return $package; }
/** * Extracts the namespace from a package * * @param \TYPO3\Flow\Package\PackageInterface $package * @return void */ protected function buildPackageNamespace(\TYPO3\Flow\Package\PackageInterface $package) { $packageNamespace = $package->getNamespace(); // Ignore legacy extensions with unkown vendor name if ($packageNamespace[0] !== '*') { $this->packageNamespaces[$packageNamespace] = array('namespaceLength' => strlen($packageNamespace), 'classesPath' => $package->getClassesPath(), 'packagePath' => $package->getPackagePath(), 'substituteNamespaceInPath' => $package instanceof PackageInterface); } }