mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 15:13:50 +00:00
fix service dependency injection for validatorInterface
This commit is contained in:
@@ -11,6 +11,7 @@ use Chill\MainBundle\Form\UserType;
|
||||
use Chill\MainBundle\Entity\GroupCenter;
|
||||
use Chill\MainBundle\Form\Type\ComposedGroupCenterType;
|
||||
use Chill\MainBundle\Form\UserPasswordType;
|
||||
use Symfony\Component\Validator\Validator\ValidatorInterface;
|
||||
|
||||
|
||||
/**
|
||||
@@ -28,14 +29,21 @@ class UserController extends AbstractController
|
||||
*/
|
||||
private $logger;
|
||||
|
||||
/**
|
||||
* @var ValidatorInterface
|
||||
*/
|
||||
private $validator;
|
||||
|
||||
/**
|
||||
* UserController constructor.
|
||||
*
|
||||
* @param LoggerInterface $logger
|
||||
* @param ValidatorInterface $validator
|
||||
*/
|
||||
public function __construct(LoggerInterface $logger)
|
||||
public function __construct(LoggerInterface $logger, ValidatorInterface $validator)
|
||||
{
|
||||
$this->logger = $logger;
|
||||
$this->validator = $validator;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -258,7 +266,7 @@ class UserController extends AbstractController
|
||||
$form[self::FORM_GROUP_CENTER_COMPOSED]->getData());
|
||||
$user->addGroupCenter($groupCenter);
|
||||
|
||||
if ($this->get('validator')->validate($user)->count() === 0) {
|
||||
if ($this->validator->validate($user)->count() === 0) {
|
||||
$em->flush();
|
||||
|
||||
$this->addFlash('success', $this->get('translator')->trans('The '
|
||||
@@ -267,7 +275,7 @@ class UserController extends AbstractController
|
||||
return $this->redirect($this->generateUrl('admin_user_edit',
|
||||
array('id' => $uid)));
|
||||
} else {
|
||||
foreach($this->get('validator')->validate($user) as $error)
|
||||
foreach($this->validator->validate($user) as $error)
|
||||
$this->addFlash('error', $error->getMessage());
|
||||
}
|
||||
}
|
||||
@@ -380,7 +388,7 @@ class UserController extends AbstractController
|
||||
|
||||
// logging for prod
|
||||
$this->logger->info('update password for an user', [
|
||||
'by' => $this->getUser()->getUsername(),
|
||||
'by' => $this->getUser()->getUsername(),
|
||||
'user' => $user->getUsername()
|
||||
]);
|
||||
|
||||
|
Reference in New Issue
Block a user