class ScriptPersister{ public function __construct( private readonly ScriptFileReader
$scriptReader,
private readonly EntityRepository
$scriptRepository,
private readonly EntityRepository
$appRepository ) { } public function updateScripts(string
$appId, Context
$context): void
{ $app =
$this->
getAppWithExistingScripts($appId,
$context);
/** @var ScriptCollection $existingScripts */
$existingScripts =
$app->
getScripts();
$scriptPaths =
$this->scriptReader->
getScriptPathsForApp($app->
getPath());
$upserts =
[];
foreach ($scriptPaths as $scriptPath) { $payload =
[ 'script' =>
$this->scriptReader->
getScriptContent($scriptPath,
$app->
getPath()),
];