public function setUserInitDate(User $user) { $accountDuration = $this->platformConfigHandler->getParameter('account_duration'); $expirationDate = new \DateTime(); $accountDuration === null ? $expirationDate->setDate(2100, 1, 1) : $expirationDate->add(new \DateInterval('P' . $accountDuration . 'D')); $user->setExpirationDate($expirationDate); $user->setInitDate(new \DateTime()); $this->objectManager->persist($user); $this->objectManager->flush(); }