Skip to content

Commit

Permalink
Use magento root directory for module manifest (#400)
Browse files Browse the repository at this point in the history
  • Loading branch information
kierenevans authored Sep 17, 2020
1 parent eaac598 commit 0957b71
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,20 @@
use Magento\Framework\App\State;
use RuntimeException;

require_once dirname(__DIR__) . '/autoload.php';

/**
* Include files from a list of glob patterns
*
* @throws RuntimeException
*
* @return void
*/
$find = function ()
{
$find = function () {
$manifest = [];
$globPatterns = require __DIR__ . '/registration_globlist.php';
$globPatterns = array_merge($globPatterns, ['src/*/*/cli_commands.php', 'src/*/*/registration.php']);
$baseDir = dirname(dirname(__DIR__)) . '/';
$baseDir = BP . '/';

foreach ($globPatterns as $globPattern) {
// Sorting is disabled intentionally for performance improvement
Expand All @@ -39,6 +41,10 @@
$manifest = array_merge($manifest, $files);
}

// Remove the base path from the manifest entries, so we return `src/...` instead of `/app/src/...`
$baseDirRegex = preg_quote($baseDir);
$manifest = preg_replace("#^$baseDirRegex#", '', $manifest);

return $manifest;
};

Expand All @@ -47,7 +53,7 @@
return $find();
}

$moduleManifestPath = dirname(dirname(__DIR__)) . '/generated/module_manifest.php';
$moduleManifestPath = BP . '/generated/module_manifest.php';

if (!file_exists($moduleManifestPath)) {
file_put_contents($moduleManifestPath, "<?php\nreturn " . var_export($find(), true) . ";");
Expand All @@ -57,7 +63,9 @@
};

$load = function ($files) {
array_map(function ($file) { require_once $file; }, $files);
array_map(function ($file) {
require_once BP . '/' . $file;
}, $files);
};

$load($cache($find));
1 change: 1 addition & 0 deletions src/magento2/application/skeleton/phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ parameters:
bootstrapFiles:
- tools/devtools-bootstrap.php
paths:
- app/etc/InviqaNonComposerComponentRegistration.php
- src
excludes_analyse:
- */src/**/registration.php

0 comments on commit 0957b71

Please sign in to comment.