[TASK] Include autoload info of all core extensions 74/40674/2
authorHelmut Hummel <helmut.hummel@typo3.org>
Fri, 26 Jun 2015 12:36:36 +0000 (14:36 +0200)
committerSascha Egerer <sascha@sascha-egerer.de>
Fri, 26 Jun 2015 14:40:36 +0000 (16:40 +0200)
Previously classes for extensions that were not loaded,
were also not autoloadable. To simplify composer installation
of the core, we now include autoload information of all extensions
that are delivered with the typo3/cms package.

By doing so, authors of distribution composer.json files
do not need to amend it with class loading information of
core extensions any more.

This means that class loading information for every
system extension will be written to typo3/contrib/vendor
by the packaging script, so that we do not need to respect
these when building additional autoload information for extensions
that are installed via the extension manager in a non composer
managed environment.

Releases: master, 7.3
Resolves: #67767
Change-Id: I1b68ebff29fc5392a0d874a17b9caa3dd4483096
Reviewed-on: http://review.typo3.org/40674
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Andreas Fernandez <typo3@scripting-base.de>
Reviewed-by: Morton Jonuschat <m.jonuschat@mojocode.de>
Tested-by: Morton Jonuschat <m.jonuschat@mojocode.de>
Reviewed-by: Daniel Goerz <ervaude@web.de>
Tested-by: Daniel Goerz <ervaude@web.de>
Reviewed-by: Sascha Egerer <sascha@sascha-egerer.de>
Tested-by: Sascha Egerer <sascha@sascha-egerer.de>
composer.json
typo3/sysext/core/Classes/Core/ClassLoadingInformationGenerator.php

index e3e4252..b6713bb 100644 (file)
        },
        "autoload": {
                "psr-4": {
+                       "TYPO3\\CMS\\About\\": "typo3/sysext/about/Classes/",
+                       "TYPO3\\CMS\\Aboutmodules\\": "typo3/sysext/aboutmodules/Classes/",
                        "TYPO3\\CMS\\Backend\\": "typo3/sysext/backend/Classes/",
+                       "TYPO3\\CMS\\Belog\\": "typo3/sysext/belog/Classes/",
+                       "TYPO3\\CMS\\Beuser\\": "typo3/sysext/beuser/Classes/",
+                       "TYPO3\\CMS\\ContextHelp\\": "typo3/sysext/context_help/Classes/",
                        "TYPO3\\CMS\\Core\\": "typo3/sysext/core/Classes/",
                        "TYPO3\\CMS\\Cshmanual\\": "typo3/sysext/cshmanual/Classes/",
+                       "TYPO3\\CMS\\CssStyledContent\\": "typo3/sysext/css_styled_content/Classes/",
+                       "TYPO3\\CMS\\Dbal\\": "typo3/sysext/dbal/Classes/",
+                       "TYPO3\\CMS\\Documentation\\": "typo3/sysext/documentation/Classes/",
                        "TYPO3\\CMS\\Extbase\\": "typo3/sysext/extbase/Classes/",
                        "TYPO3\\CMS\\Extensionmanager\\": "typo3/sysext/extensionmanager/Classes/",
+                       "TYPO3\\CMS\\Feedit\\": "typo3/sysext/feedit/Classes/",
+                       "TYPO3\\CMS\\Felogin\\": "typo3/sysext/felogin/Classes/",
+                       "TYPO3\\CMS\\Filelist\\": "typo3/sysext/filelist/Classes/",
                        "TYPO3\\CMS\\Fluid\\": "typo3/sysext/fluid/Classes/",
+                       "TYPO3\\CMS\\Form\\": "typo3/sysext/form/Classes/",
                        "TYPO3\\CMS\\Frontend\\": "typo3/sysext/frontend/Classes/",
+                       "TYPO3\\CMS\\Func\\": "typo3/sysext/func/Classes/",
+                       "TYPO3\\CMS\\Impexp\\": "typo3/sysext/impexp/Classes/",
+                       "TYPO3\\CMS\\IndexedSearch\\": "typo3/sysext/indexed_search/Classes/",
+                       "TYPO3\\CMS\\IndexedSearchMysql\\": "typo3/sysext/indexed_search_mysql/Classes/",
+                       "TYPO3\\CMS\\Info\\": "typo3/sysext/info/Classes/",
+                       "TYPO3\\CMS\\InfoPagetsconfig\\": "typo3/sysext/info_pagetsconfig/Classes/",
                        "TYPO3\\CMS\\Install\\": "typo3/sysext/install/Classes/",
                        "TYPO3\\CMS\\Lang\\": "typo3/sysext/lang/Classes/",
+                       "TYPO3\\CMS\\Linkvalidator\\": "typo3/sysext/linkvalidator/Classes/",
+                       "TYPO3\\CMS\\Lowlevel\\": "typo3/sysext/lowlevel/Classes/",
+                       "TYPO3\\CMS\\Mediace\\": "typo3/sysext/mediace/Classes/",
+                       "TYPO3\\CMS\\Opendocs\\": "typo3/sysext/opendocs/Classes/",
+                       "TYPO3\\CMS\\Openid\\": "typo3/sysext/openid/Classes/",
                        "TYPO3\\CMS\\Recordlist\\": "typo3/sysext/recordlist/Classes/",
+                       "TYPO3\\CMS\\Recycler\\": "typo3/sysext/recycler/Classes/",
+                       "TYPO3\\CMS\\Reports\\": "typo3/sysext/reports/Classes/",
+                       "TYPO3\\CMS\\Rsaauth\\": "typo3/sysext/rsaauth/Classes/",
+                       "TYPO3\\CMS\\Rtehtmlarea\\": "typo3/sysext/rtehtmlarea/Classes/",
                        "TYPO3\\CMS\\Saltedpasswords\\": "typo3/sysext/saltedpasswords/Classes/",
+                       "TYPO3\\CMS\\Scheduler\\": "typo3/sysext/scheduler/Classes/",
+                       "TYPO3\\CMS\\Setup\\": "typo3/sysext/setup/Classes/",
                        "TYPO3\\CMS\\Sv\\": "typo3/sysext/sv/Classes/",
-                       "TYPO3\\CMS\\T3skin\\": "typo3/sysext/t3skin/Classes/"
+                       "TYPO3\\CMS\\SysAction\\": "typo3/sysext/sys_action/Classes/",
+                       "TYPO3\\CMS\\SysNote\\": "typo3/sysext/sys_note/Classes/",
+                       "TYPO3\\CMS\\T3editor\\": "typo3/sysext/t3editor/Classes/",
+                       "TYPO3\\CMS\\T3skin\\": "typo3/sysext/t3skin/Classes/",
+                       "TYPO3\\CMS\\Taskcenter\\": "typo3/sysext/taskcenter/Classes/",
+                       "TYPO3\\CMS\\Tstemplate\\": "typo3/sysext/tstemplate/Classes/",
+                       "TYPO3\\CMS\\Version\\": "typo3/sysext/version/Classes/",
+                       "TYPO3\\CMS\\Viewpage\\": "typo3/sysext/viewpage/Classes/",
+                       "TYPO3\\CMS\\WizardCrpages\\": "typo3/sysext/wizard_crpages/Classes/",
+                       "TYPO3\\CMS\\WizardSortpages\\": "typo3/sysext/wizard_sortpages/Classes/",
+                       "TYPO3\\CMS\\Workspaces\\": "typo3/sysext/workspaces/Classes/"
                },
                "classmap": [
                        "typo3/sysext/core/Resources/PHP/"
                        "TYPO3\\CMS\\Install\\Tests\\": "typo3/sysext/install/Tests/",
                        "TYPO3\\CMS\\Lang\\Tests\\": "typo3/sysext/lang/Tests/",
                        "TYPO3\\CMS\\Lowlevel\\Tests\\": "typo3/sysext/lowlevel/Tests/",
+                       "TYPO3\\CMS\\Mediace\\Tests\\": "typo3/sysext/mediace/Tests/",
                        "TYPO3\\CMS\\Recordlist\\Tests\\": "typo3/sysext/recordlist/Tests/",
                        "TYPO3\\CMS\\Reports\\Tests\\": "typo3/sysext/reports/Tests/",
                        "TYPO3\\CMS\\Rsaauth\\Tests\\": "typo3/sysext/rsaauth/Tests/",
                }
        },
        "include-path": [
-               "./typo3/contrib/vendor/pear/http_request2"
+               "typo3/contrib/vendor/pear/http_request2/"
        ]
 }
index 47934a8..94a1f2c 100644 (file)
@@ -28,9 +28,14 @@ use TYPO3\CMS\Core\Utility\PathUtility;
 class ClassLoadingInformationGenerator {
 
        /**
+        * Folder with framework extensions
+        */
+       const SYSEXT_FOLDER = 'typo3/sysext';
+
+       /**
         * @var PackageInterface[]
         */
-       static protected $activePackages;
+       static protected $activeExtensionPackages;
 
        /**
         * Returns class loading information for a single package
@@ -107,7 +112,7 @@ class ClassLoadingInformationGenerator {
         */
        static public function buildAutoloadInformationFiles() {
                // Ensure that for each re-build, the packages are fetched again from the package manager
-               self::$activePackages = NULL;
+               self::$activeExtensionPackages = NULL;
 
                $psr4File = $classMapFile = <<<EOF
 <?php
@@ -121,7 +126,7 @@ return array(
 EOF;
                $classMap = array();
                $psr4 = array();
-               foreach (self::getActivePackages() as $package) {
+               foreach (self::getActiveExtensionPackages() as $package) {
                        $classLoadingInformation = self::buildClassLoadingInformationForPackage($package, TRUE);
                        $classMap = array_merge($classMap, $classLoadingInformation['classMap']);
                        $psr4 = array_merge($psr4, $classLoadingInformation['psr-4']);
@@ -178,7 +183,7 @@ EOF;
        static public function buildClassAliasMapFile() {
                $aliasToClassNameMapping = array();
                $classNameToAliasMapping = array();
-               foreach (self::getActivePackages() as $package) {
+               foreach (self::getActiveExtensionPackages() as $package) {
                        $aliasMappingForPackage = self::buildClassAliasMapForPackage($package);
                        $aliasToClassNameMapping = array_merge($aliasToClassNameMapping, $aliasMappingForPackage['aliasToClassNameMapping']);
                        $classNameToAliasMapping = array_merge($classNameToAliasMapping, $aliasMappingForPackage['classNameToAliasMapping']);
@@ -198,20 +203,29 @@ EOF;
         *
         * @return \TYPO3\CMS\Core\Package\PackageInterface[]
         */
-       static protected function getActivePackages() {
-               if (self::$activePackages === NULL) {
-                       self::$activePackages = array();
+       static protected function getActiveExtensionPackages() {
+               if (self::$activeExtensionPackages === NULL) {
+                       self::$activeExtensionPackages = array();
                        foreach (self::getPackageManager()->getActivePackages() as $package) {
-                               if (!$package instanceof \TYPO3\CMS\Core\Package\Package || $package->isProtected()) {
-                                       // Skip non core packages and all protected packages.
-                                       // The latter will be covered by composer class loader.
+                               if (self::isFrameworkPackage($package)) {
+                                       // Skip all core packages as the class loading info is prepared for them already
                                        continue;
                                }
-                               self::$activePackages[] = $package;
+                               self::$activeExtensionPackages[] = $package;
                        }
                }
 
-               return self::$activePackages;
+               return self::$activeExtensionPackages;
+       }
+
+       /**
+        * Check if the package is a framework package (located in typo3/sysext)
+        *
+        * @param PackageInterface $package
+        * @return bool
+        */
+       static protected function isFrameworkPackage(PackageInterface $package) {
+               return strpos($package->getPackagePath(), self::SYSEXT_FOLDER) !== FALSE;
        }
 
        /**