setBasket( $this->getReference('one-basket') // load the one-basket stored reference ); $expires = new \DateTime(); $expires->modify('+1 week'); $validationSession->setExpires($expires); if (null === $this->user) { throw new \LogicException('Fill a user to store a new validation Session'); } $validationSession->setInitiator($this->user); $manager->persist($validationSession); $manager->flush(); $this->validationSession = $validationSession; $this->addReference('one-validation-session', $validationSession); } }