/**
  * Returns class alias map for given package
  *
  * @param PackageInterface $package The package to generate the class alias info for
  * @throws \TYPO3\CMS\Core\Error\Exception
  * @return array
  */
 public static function buildClassAliasMapForPackage(PackageInterface $package)
 {
     $aliasToClassNameMapping = array();
     $classNameToAliasMapping = array();
     $possibleClassAliasFile = $package->getPackagePath() . 'Migrations/Code/ClassAliasMap.php';
     if (file_exists($possibleClassAliasFile)) {
         $packageAliasMap = (require $possibleClassAliasFile);
         if (!is_array($packageAliasMap)) {
             throw new \TYPO3\CMS\Core\Error\Exception('"class alias maps" must return an array', 1422625075);
         }
         foreach ($packageAliasMap as $aliasClassName => $className) {
             $lowerCasedAliasClassName = strtolower($aliasClassName);
             $aliasToClassNameMapping[$lowerCasedAliasClassName] = $className;
             $classNameToAliasMapping[$className][$lowerCasedAliasClassName] = $lowerCasedAliasClassName;
         }
     }
     return array('aliasToClassNameMapping' => $aliasToClassNameMapping, 'classNameToAliasMapping' => $classNameToAliasMapping);
 }
Exemple #2
0
 /**
  * Returns "System", "Global" or "Local" based on extension position in filesystem.
  *
  * @param PackageInterface $package
  * @return string
  */
 protected function getInstallTypeForPackage(PackageInterface $package)
 {
     foreach (\TYPO3\CMS\Extensionmanager\Domain\Model\Extension::returnInstallPaths() as $installType => $installPath) {
         if (GeneralUtility::isFirstPartOfStr($package->getPackagePath(), $installPath)) {
             return $installType;
         }
     }
     return '';
 }
 /**
  * Returns class alias map for given package
  *
  * @param PackageInterface $package The package to generate the class alias info for
  * @throws \TYPO3\CMS\Core\Error\Exception
  * @return array
  */
 public function buildClassAliasMapForPackage(PackageInterface $package)
 {
     $aliasToClassNameMapping = [];
     $classNameToAliasMapping = [];
     $possibleClassAliasFiles = [];
     $manifest = $package->getValueFromComposerManifest();
     if (!empty($manifest->extra->{'typo3/class-alias-loader'}->{'class-alias-maps'})) {
         $possibleClassAliasFiles = $manifest->extra->{'typo3/class-alias-loader'}->{'class-alias-maps'};
         if (!is_array($possibleClassAliasFiles)) {
             throw new \TYPO3\CMS\Core\Error\Exception('"typo3/class-alias-loader"/"class-alias-maps" must return an array!', 1444142481);
         }
     } else {
         $possibleClassAliasFiles[] = 'Migrations/Code/ClassAliasMap.php';
     }
     $packagePath = $package->getPackagePath();
     foreach ($possibleClassAliasFiles as $possibleClassAliasFile) {
         $possiblePathToClassAliasFile = $packagePath . $possibleClassAliasFile;
         if (file_exists($possiblePathToClassAliasFile)) {
             $packageAliasMap = (require $possiblePathToClassAliasFile);
             if (!is_array($packageAliasMap)) {
                 throw new \TYPO3\CMS\Core\Error\Exception('"class alias maps" must return an array', 1422625075);
             }
             foreach ($packageAliasMap as $aliasClassName => $className) {
                 $lowerCasedAliasClassName = strtolower($aliasClassName);
                 $aliasToClassNameMapping[$lowerCasedAliasClassName] = $className;
                 $classNameToAliasMapping[$className][$lowerCasedAliasClassName] = $lowerCasedAliasClassName;
             }
         }
     }
     return array('aliasToClassNameMapping' => $aliasToClassNameMapping, 'classNameToAliasMapping' => $classNameToAliasMapping);
 }
 /**
  * Register a native TYPO3 package
  *
  * @param PackageInterface $package The Package to be registered
  * @param bool $sortAndSave allows for not saving packagestates when used in loops etc.
  * @return PackageInterface
  * @throws Exception\InvalidPackageStateException
  * @throws Exception\PackageStatesFileNotWritableException
  */
 public function registerPackage(PackageInterface $package, $sortAndSave = TRUE)
 {
     $packageKey = $package->getPackageKey();
     if ($this->isPackageAvailable($packageKey)) {
         throw new Exception\InvalidPackageStateException('Package "' . $packageKey . '" is already registered.', 1338996122);
     }
     $this->packages[$packageKey] = $package;
     $this->packageStatesConfiguration['packages'][$packageKey]['packagePath'] = str_replace($this->packagesBasePath, '', $package->getPackagePath());
     if ($sortAndSave === TRUE) {
         $this->sortAndSavePackageStates();
     }
     if ($package instanceof PackageInterface) {
         foreach ($package->getPackageReplacementKeys() as $packageToReplace => $versionConstraint) {
             $this->packageAliasMap[strtolower($packageToReplace)] = $package->getPackageKey();
         }
     }
     return $package;
 }
Exemple #5
0
 /**
  * @param PackageInterface $package
  */
 protected function registerActivePackage(PackageInterface $package)
 {
     // reset the active packages so they are rebuilt.
     $this->activePackages = [];
     $this->packageStatesConfiguration['packages'][$package->getPackageKey()] = ['packagePath' => str_replace($this->packagesBasePath, '', $package->getPackagePath())];
 }
 /**
  * Check if the package is a framework package (located in typo3/sysext)
  *
  * @param PackageInterface $package
  * @return bool
  */
 protected static function isFrameworkPackage(PackageInterface $package)
 {
     return strpos($package->getPackagePath(), self::SYSEXT_FOLDER) !== FALSE;
 }