get(EventDispatcherInterface::class); $dispatcher->dispatch(new CronEvent()); try { // Persist data /** @var EntityManagerInterface $em */ $em = $container->get(EntityManagerInterface::class); $em->flush(); } catch (NotFoundExceptionInterface) { // Do nothing }