/** * Updates the failure report */ public function updateReport() { if (null === $this->start) { $this->start = new \DateTime(); $this->attemptCount++; $event = new AuthenticationAttemptEvent($this->relatedUser); $event->setReport($this->createReport()); DomainEvents::raise($event); } else { $intervalTimestamp = $this->start->getTimestamp(); if (time() - $intervalTimestamp > 86400) { $this->start = new \DateTime(); $this->attemptCount = 1; } else { $this->attemptCount++; if (time() - $intervalTimestamp >= 21600) { $event = new AuthenticationAttemptEvent($this->relatedUser); $event->setReport($this->createReport()); DomainEvents::raise($event); } } } }
/** * @expectedException \LogicException * @expectedExceptionMessage Invalid event object (Symfony\Component\EventDispatcher\Event) given! */ public function testRaiseWithInvalidClass() { DomainEvents::setEventDispatcher(new EventDispatcher()); DomainEvents::raise(new Event()); }
/** * Resets the password * * @param ActivationKeyCodeGeneratorInterface $stringGenerator */ public function resetPassword(ActivationKeyCodeGeneratorInterface $stringGenerator) { $this->ensureActivated(); $password = $stringGenerator->generateKey(8); $this->credentials = $this->getFactory()->modifyValueObject($this->credentials, ['password' => new Password($password, true)]); $event = new ResetPasswordEvent($this); $event->setNewRawPassword($password); DomainEvents::raise($event); }