Files
compras/integrations/sgf/operational/entry.php
T
nala c9bd6db90b
tests / ci (push) Canceled after 0s
commit compras2 3011
2026-11-30 23:04:25 +02:00

36 lines
1.9 KiB
PHP

<?php
use Tempo\Purchasing\Inventory\StockCosting;
// Copied as <local bundle>/bootstrap.php, without a source-project dependency.
if (config('merchandise_invoices.costs_enabled') === true) {
(static function (): void {
if (! is_file(__DIR__.'/manifest.json') || is_link(__DIR__.'/manifest.json') || ! is_readable(__DIR__.'/manifest.json')) {
throw new RuntimeException('Manifesto local da composição ausente.');
}
$relative = 'packages/purchasing/src/StockCosting.php';
$manifest = json_decode(file_get_contents(__DIR__.'/manifest.json'), true, 32, JSON_THROW_ON_ERROR);
$pin = $manifest['support_files'][$relative] ?? null;
$file = realpath(__DIR__.'/'.$relative);
$base = realpath(__DIR__);
if (! in_array($manifest['format'] ?? null, ['tempo.operational-review.v1', 'tempo.operational-review.v2'], true)
|| ! is_string($pin) || ! preg_match('/^[a-f0-9]{64}$/D', $pin) || ! $file || ! $base
|| ! str_starts_with(strtolower($file), strtolower($base.DIRECTORY_SEPARATOR))
|| is_link(__DIR__.'/'.$relative) || ! hash_equals($pin, hash_file('sha256', $file))) {
throw new RuntimeException('Cálculo comum da composição ausente ou divergente.');
}
$class = StockCosting::class;
if (class_exists($class, false)) {
if (! hash_equals($pin, hash_file('sha256', (new ReflectionClass($class))->getFileName()))) {
throw new RuntimeException('Outra versão do cálculo comum já foi carregada.');
}
} else {
require_once $file;
}
})();
}
require_once __DIR__.'/integrations/sgf/operational/bootstrap.php';
require_once __DIR__.'/integrations/sgf/operational/RuntimeContext.php';
require_once __DIR__.'/integrations/sgf/operational/Composition.php';
require_once __DIR__.'/integrations/sgf/sourcing/bootstrap.php';