Skip to content

Commit

Permalink
Fix scope of routes with method name in production Phar
Browse files Browse the repository at this point in the history
  • Loading branch information
aschempp committed Feb 16, 2024
1 parent 5cb1151 commit fa14f79
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions scoper.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,9 @@ static function (string $filePath, string $prefix, string $contents): string {
);
},

// Fix error templates (e.g. /vendor/symfony/error-handler/Resources/views)
// Disable HtmlErrorRenderer::fileExcerpt breaking due to high memory load
static function (string $filePath, string $prefix, string $contents): string {
if (!str_starts_with($filePath, 'vendor/symfony/error-handler/ErrorRenderer/HtmlErrorRenderer.php')) {
if ('vendor/symfony/error-handler/ErrorRenderer/HtmlErrorRenderer.php' !== $filePath) {
return $contents;
}

Expand All @@ -149,11 +149,20 @@ static function (string $filePath, string $prefix, string $contents): string {

// Fix prod container cache path
static function (string $filePath, string $prefix, string $contents): string {
if (!str_starts_with($filePath, 'vendor/symfony/http-kernel/Kernel.php')) {
if ('vendor/symfony/http-kernel/Kernel.php' !== $filePath) {
return $contents;
}

return str_replace("\$buildDir . '/' . \$class . '.php'", "\$buildDir.'/'.str_replace('".$prefix."_', '', \$class).'.php'", $contents);
},

// Fix routes controllers with method argument
static function (string $filePath, string $prefix, string $contents): string {
if (!str_starts_with($filePath, 'api/Resources/cache/')) {
return $contents;
}

return str_replace("'Contao\\\\ManagerApi\\\\", "'$prefix\\\\Contao\\\\ManagerApi\\\\", $contents);
},
],
];

0 comments on commit fa14f79

Please sign in to comment.