コード例 #1
0
 function let(Generator $generator, HasInitialPassword $user, LifecycleEventArgs $event)
 {
     $generator->generate()->willReturn('password');
     $event->getObject()->willReturn($user);
     $user->getPlainPassword()->willReturn(null);
     $this->beConstructedWith($generator);
 }
コード例 #2
0
 /**
  * @param LifecycleEventArgs $event
  *
  * @return false|void False if nothing was done
  */
 public function prePersist(LifecycleEventArgs $event)
 {
     $object = $event->getObject();
     if (false === $object instanceof HasInitialPassword) {
         return false;
     }
     if (null !== $object->getPlainPassword()) {
         return false;
     }
     $plainPassword = $this->generator->generate();
     $object->setPlainPassword($plainPassword);
 }