minor fixes and user events docs

This commit is contained in:
Antonio Ramirez
2017-06-12 18:51:20 +02:00
parent 335a60383c
commit 4a80593435
10 changed files with 155 additions and 12 deletions

View File

@ -39,17 +39,23 @@ class UserBlockService implements ServiceInterface
public function run()
{
if ($this->model->getIsBlocked()) {
$this->controller->trigger(UserEvent::EVENT_BEFORE_UNBLOCK, $this->event);
$this->triggerEvents(UserEvent::EVENT_BEFORE_UNBLOCK);
$result = (bool)$this->model->updateAttributes(['blocked_at' => null]);
$this->controller->trigger(UserEvent::EVENT_AFTER_UNBLOCK, $this->event);
$this->triggerEvents(UserEvent::EVENT_AFTER_UNBLOCK);
} else {
$this->controller->trigger(UserEvent::EVENT_BEFORE_BLOCK, $this->event);
$this->triggerEvents(UserEvent::EVENT_BEFORE_BLOCK);
$result = (bool)$this->model->updateAttributes(
['blocked_at' => time(), 'auth_key' => $this->securityHelper->generateRandomString()]
);
$this->controller->trigger(UserEvent::EVENT_AFTER_BLOCK, $this->event);
$this->triggerEvents(UserEvent::EVENT_AFTER_BLOCK);
}
return $result;
}
protected function triggerEvents($name)
{
$this->controller->trigger($name, $this->event);
$this->model->trigger($name, $this->event);
}
}