isFile() && ! $file->isLink()) { $support[$directory.'/'.$file->getFilename()] = file_get_contents($file->getPathname()); } } } ksort($support); $support['scripts/sgf-internal-install.php'] = file_get_contents($root.'/scripts/sgf-internal-install.php'); $support['bootstrap.php'] = file_get_contents($root.'/integrations/sgf/operational/entry.php'); $hash = hash('sha256', json_encode([$files, $support], JSON_THROW_ON_ERROR)); $directory = $root.'/storage/app/private/candidates/OPERATIONAL-CANDIDATE-'.substr($hash, 0, 16); $manifest = ['format' => 'tempo.operational-review.v1', 'installed' => false, 'activated' => false, 'host_version_preserved' => '0.1.1', 'host_overlays' => [], 'support_files' => []]; foreach ($files as $path => $file) { $support[$path] = $file['contents']; unset($file['contents']); $manifest['host_overlays'][$path] = $file; } foreach ($support as $path => $contents) { $target = $directory.'/'.$path; if (! is_dir(dirname($target))) { mkdir(dirname($target), 0700, true); } if (is_file($target) && hash_file('sha256', $target) !== hash('sha256', $contents)) { throw new RuntimeException('Candidata imutável divergente.'); } file_put_contents($target, $contents); $manifest['support_files'][$path] = hash('sha256', $contents); } file_put_contents($directory.'/manifest.json', json_encode($manifest, JSON_PRETTY_PRINT | JSON_THROW_ON_ERROR)); echo json_encode(['directory' => $directory, 'installed' => false], JSON_THROW_ON_ERROR)."\n";