added internal rates (#1591)

This commit is contained in:
Kevin Papst
2020-04-08 14:50:15 +02:00
committed by GitHub
parent 82c713031e
commit 68d703d1e3
128 changed files with 4044 additions and 1571 deletions

View File

@@ -14,6 +14,8 @@ use FOS\UserBundle\Event\FormEvent;
use FOS\UserBundle\FOSUserEvents;
use FOS\UserBundle\Model\UserManagerInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
/**
* This class intercepts the registration to make sure:
@@ -21,19 +23,21 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface;
* - the first-ever registered user will get the SUPER_ADMIN role
* - the user uses the current request locale as initial language setting
*/
class RegistrationSubscriber implements EventSubscriberInterface
final class RegistrationSubscriber implements EventSubscriberInterface
{
/**
* @var UserManagerInterface
*/
protected $userManager;
private $userManager;
/**
* @param UserManagerInterface $userManager
* @var UrlGeneratorInterface
*/
public function __construct(UserManagerInterface $userManager)
private $router;
public function __construct(UserManagerInterface $userManager, UrlGeneratorInterface $router)
{
$this->userManager = $userManager;
$this->router = $router;
}
/**
@@ -42,7 +46,8 @@ class RegistrationSubscriber implements EventSubscriberInterface
public static function getSubscribedEvents(): array
{
return [
FOSUserEvents::REGISTRATION_SUCCESS => ['onRegistrationSuccess', 200]
FOSUserEvents::REGISTRATION_SUCCESS => ['onRegistrationSuccess', 200],
FOSUserEvents::RESETTING_RESET_SUCCESS => ['onResettingSuccess', 200],
];
}
@@ -62,4 +67,12 @@ class RegistrationSubscriber implements EventSubscriberInterface
$user->setLanguage($event->getRequest()->getLocale());
$user->setRoles($roles);
}
/**
* @param FormEvent $event
*/
public function onResettingSuccess(FormEvent $event)
{
$event->setResponse(new RedirectResponse($this->router->generate('my_profile')));
}
}

View File

@@ -111,6 +111,15 @@ class UserPreferenceSubscriber implements EventSubscriberInterface
->setOptions($hourlyRateOptions)
->addConstraint(new Range(['min' => 0])),
(new UserPreference())
->setName(UserPreference::INTERNAL_RATE)
->setValue(null)
->setOrder(101)
->setType(MoneyType::class)
->setEnabled($enableHourlyRate)
->setOptions(array_merge($hourlyRateOptions, ['label' => 'label.rate_internal', 'required' => false]))
->addConstraint(new Range(['min' => 0])),
(new UserPreference())
->setName(UserPreference::TIMEZONE)
->setValue($this->getDefaultTimezone())