@@ -14,10 +14,35 @@ final class BootOverlay
|
||||
if (str_ends_with($path, 'AppServiceProvider.php')) {
|
||||
$old = '$this->app->scoped(CompanyContext::class';
|
||||
$new = "if (is_file(base_path('packages/internal-requisitions/bootstrap.php'))) { require_once base_path('packages/internal-requisitions/bootstrap.php'); }\n ".$old;
|
||||
$source = self::replace($source, $old, $new);
|
||||
$source = self::replace($source, "public function boot(): void\n {", "public function boot(): void\n {\n if (is_file(base_path('packages/internal-requisitions/bootstrap.php'))) { \$this->loadRoutesFrom(base_path('packages/internal-requisitions/integrations/sgf/operational/routes.php')); }");
|
||||
if (! str_contains($source, "base_path('packages/internal-requisitions/bootstrap.php')")) {
|
||||
$source = self::replace($source, $old, $new);
|
||||
} elseif (substr_count($source, $new) !== 1) {
|
||||
throw new \RuntimeException('Arranque de Compras divergente; reconciliar antes de preparar.');
|
||||
}
|
||||
$boot = "public function boot(): void\n {";
|
||||
$mounted = $boot."\n if (is_file(base_path('packages/internal-requisitions/bootstrap.php'))) { \$this->loadRoutesFrom(base_path('packages/internal-requisitions/integrations/sgf/operational/routes.php')); }";
|
||||
if (! str_contains($source, 'packages/internal-requisitions/integrations/sgf/operational/routes.php')) {
|
||||
$source = self::replace($source, $boot, $mounted);
|
||||
} elseif (substr_count($source, $mounted) !== 1) {
|
||||
throw new \RuntimeException('Rotas de Compras divergentes; reconciliar antes de preparar.');
|
||||
}
|
||||
} else {
|
||||
$source = self::replace($source, "'purchasing'=>['purchasing_budget.', 'supplier_payables.']", "'purchasing'=>['purchasing_budget.', 'purchasing_requisitions.', 'supplier_payables.']");
|
||||
$count = 0;
|
||||
$source = preg_replace_callback("~('purchasing'\\s*=>\\s*\\[)([^\\[\\]]*)(\\])~", static function (array $match): string {
|
||||
// Extend only the declared prefix list; preserve every later host capability.
|
||||
if (! preg_match("~^\\s*'[a-z_]+\\.'(?:\\s*,\\s*'[a-z_]+\\.')*\\s*,?\\s*$~", $match[2])
|
||||
|| ! str_contains($match[2], "'purchasing_budget.'") || ! str_contains($match[2], "'supplier_payables.'")) {
|
||||
throw new \RuntimeException('Navegação de Compras divergente; lista explícita requerida.');
|
||||
}
|
||||
if (str_contains($match[2], "'purchasing_requisitions.'")) {
|
||||
return $match[0];
|
||||
}
|
||||
|
||||
return $match[1]."'purchasing_requisitions.', ".$match[2].$match[3];
|
||||
}, $source, -1, $count);
|
||||
if ($source === null || $count !== 1) {
|
||||
throw new \RuntimeException('Navegação de Compras ausente ou ambígua; reconciliar antes de preparar.');
|
||||
}
|
||||
}
|
||||
$result[$path] = ['before_sha256' => $hash, 'after_sha256' => hash('sha256', $source), 'contents' => $source];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user