entityManager = $entityManager; $this->serviceFactory = $serviceFactory; } public function run(Request $request) { $entityId = $request->get('entityId'); $entityType = $request->get('entityType'); $templateId = $request->get('templateId'); if (!$entityId || !$entityType || !$templateId) { throw new BadRequest(); } $entity = $this->entityManager->getEntity($entityType, $entityId); $template = $this->entityManager->getEntity('Template', $templateId); if (!$entity || !$template) { throw new NotFound(); } $this->serviceFactory->create('Pdf')->buildFromTemplate($entity, $template, true); exit; } }