class TemplatePersister{ public function __construct( private readonly AbstractTemplateLoader
$templateLoader,
private readonly EntityRepository
$templateRepository,
private readonly EntityRepository
$appRepository ) { } public function updateTemplates(Manifest
$manifest, string
$appId, Context
$context): void
{ $app =
$this->
getAppWithExistingTemplates($appId,
$context);
/** @var TemplateCollection $existingTemplates */
$existingTemplates =
$app->
getTemplates();
$templatePaths =
$this->templateLoader->
getTemplatePathsForApp($manifest);
$upserts =
[];
foreach ($templatePaths as $templatePath) { $payload =
[ 'template' =>
$this->templateLoader->
getTemplateContent($templatePath,
$manifest),
];
/** @var TemplateEntity|null $existing */