@@ -61,10 +61,12 @@ class Bootstrap
61
61
62
62
public function register (): void
63
63
{
64
- $ finder = new DrupalFinder ();
65
- $ finder ->locateRoot (dirname ($ GLOBALS ['autoloaderInWorkingDirectory ' ], 2 ));
66
- $ this ->autoloader = include $ finder ->getVendorDir () . '/autoload.php ' ;
67
- $ this ->drupalRoot = $ finder ->getDrupalRoot ();
64
+ $ drupalRoot = realpath ($ GLOBALS ['drupalRoot ' ]);
65
+ if ($ drupalRoot === false ) {
66
+ throw new \RuntimeException ('Cannot determine the Drupal root from ' . $ drupalRoot );
67
+ }
68
+ $ this ->drupalRoot = $ drupalRoot ;
69
+ $ this ->autoloader = include realpath ($ GLOBALS ['drupalVendorDir ' ]) . '/autoload.php ' ;
68
70
69
71
$ this ->extensionDiscovery = new ExtensionDiscovery ($ this ->drupalRoot );
70
72
$ this ->extensionDiscovery ->setProfileDirectories ([]);
@@ -80,13 +82,11 @@ public function register(): void
80
82
return $ a ->getName () === 'blazy_test ' ? 10 : 0 ;
81
83
});
82
84
$ this ->themeData = $ this ->extensionDiscovery ->scan ('theme ' );
83
-
84
- $ this ->loadLegacyIncludes ();
85
-
86
85
$ this ->addCoreNamespaces ();
87
86
$ this ->addModuleNamespaces ();
88
87
$ this ->addThemeNamespaces ();
89
88
$ this ->registerPs4Namespaces ($ this ->namespaces );
89
+ $ this ->loadLegacyIncludes ();
90
90
91
91
foreach ($ this ->moduleData as $ extension ) {
92
92
$ this ->loadExtension ($ extension );
@@ -95,8 +95,10 @@ public function register(): void
95
95
$ module_dir = $ this ->drupalRoot . '/ ' . $ extension ->getPath ();
96
96
// Add .install
97
97
if (file_exists ($ module_dir . '/ ' . $ module_name . '.install ' )) {
98
- // Causes errors on Drupal container not initialized
99
- // require $module_dir . '/' . $module_name . '.install';
98
+ $ ignored_install_files = ['entity_test ' , 'entity_test_update ' , 'update_test_schema ' ];
99
+ if (!in_array ($ module_name , $ ignored_install_files , true )) {
100
+ require $ module_dir . '/ ' . $ module_name . '.install ' ;
101
+ }
100
102
}
101
103
// Add .post_update.php
102
104
if (file_exists ($ module_dir . '/ ' . $ module_name . '.post_update.php ' )) {
@@ -131,16 +133,12 @@ protected function loadLegacyIncludes(): void
131
133
132
134
protected function addCoreNamespaces (): void
133
135
{
136
+ require $ this ->drupalRoot . '/core/lib/Drupal.php ' ;
134
137
foreach (['Core ' , 'Component ' ] as $ parent_directory ) {
135
138
$ path = $ this ->drupalRoot . '/core/lib/Drupal/ ' . $ parent_directory ;
136
139
$ parent_namespace = 'Drupal \\' . $ parent_directory ;
137
140
foreach (new \DirectoryIterator ($ path ) as $ component ) {
138
- $ pathname = $ component ->getPathname ();
139
- if (!$ component ->isDot () && $ component ->isDir () && (
140
- is_dir ($ pathname . '/Plugin ' ) ||
141
- is_dir ($ pathname . '/Entity ' ) ||
142
- is_dir ($ pathname . '/Element ' )
143
- )) {
141
+ if (!$ component ->isDot () && $ component ->isDir ()) {
144
142
$ this ->namespaces [$ parent_namespace . '\\' . $ component ->getFilename ()] = $ path . '/ ' . $ component ->getFilename ();
145
143
}
146
144
}
0 commit comments