|
4 | 4 | * See COPYING.txt for license details.
|
5 | 5 | */
|
6 | 6 |
|
7 |
| -$pathList[] = dirname(__DIR__) . '/code/*/*/cli_commands.php'; |
8 |
| -$pathList[] = dirname(__DIR__) . '/code/*/*/registration.php'; |
9 |
| -$pathList[] = dirname(__DIR__) . '/design/*/*/*/registration.php'; |
10 |
| -$pathList[] = dirname(__DIR__) . '/i18n/*/*/registration.php'; |
11 |
| -$pathList[] = dirname(dirname(__DIR__)) . '/lib/internal/*/*/registration.php'; |
12 |
| -$pathList[] = dirname(dirname(__DIR__)) . '/lib/internal/*/*/*/registration.php'; |
13 |
| -foreach ($pathList as $path) { |
14 |
| - // Sorting is disabled intentionally for performance improvement |
15 |
| - $files = glob($path, GLOB_NOSORT); |
16 |
| - if ($files === false) { |
17 |
| - throw new \RuntimeException('glob() returned error while searching in \'' . $path . '\''); |
18 |
| - } |
19 |
| - foreach ($files as $file) { |
20 |
| - include $file; |
| 7 | +namespace Magento\NonComposerComponentRegistration; |
| 8 | + |
| 9 | +use RuntimeException; |
| 10 | + |
| 11 | +/** |
| 12 | + * Include files from a list of glob patterns |
| 13 | + * |
| 14 | + * @throws RuntimeException |
| 15 | + * @return void |
| 16 | + */ |
| 17 | +function main() |
| 18 | +{ |
| 19 | + $globPatterns = include __DIR__ . '/include-globlist.php'; |
| 20 | + $baseDir = dirname(__DIR__) . '/'; |
| 21 | + |
| 22 | + foreach ($globPatterns as $globPattern) { |
| 23 | + // Sorting is disabled intentionally for performance improvement |
| 24 | + $files = glob($baseDir . $globPattern, GLOB_NOSORT); |
| 25 | + if ($files === false) { |
| 26 | + throw new RuntimeException("glob(): error with '$baseDir$globPattern'"); |
| 27 | + } |
| 28 | + array_map(__NAMESPACE__ . '\file', $files); |
21 | 29 | }
|
22 | 30 | }
|
| 31 | + |
| 32 | +/** |
| 33 | + * Isolated include with it's own variable scope |
| 34 | + * |
| 35 | + * @return void |
| 36 | + */ |
| 37 | +function file() { |
| 38 | + include func_get_arg(0); |
| 39 | +} |
| 40 | + |
| 41 | +main(); |
0 commit comments