attributes->get('slug') ?? $context['request']?->attributes->get('_route_params')['slug'] ?? ''; $application = $this->applicationRepository->findOneBy(['slug' => $slug]); if (null === $application) { throw new NotFoundHttpException(sprintf('Application "%s" not found.', $slug)); } $data->setApplication($application); $this->entityManager->persist($data); $this->entityManager->flush(); return $data; } }