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:
@@ -14,6 +14,7 @@ use Symfony\Component\Security\Core\Role\Role;
|
||||
use Symfony\Component\Security\Core\Role\RoleHierarchy;
|
||||
use Chill\MainBundle\Entity\Scope;
|
||||
use Chill\MainBundle\Form\Type\ComposedRoleScopeType;
|
||||
use Symfony\Component\Validator\Validator\ValidatorInterface;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
/**
|
||||
@@ -43,6 +44,11 @@ class PermissionsGroupController extends AbstractController
|
||||
*/
|
||||
private $translator;
|
||||
|
||||
/**
|
||||
* @var ValidatorInterface
|
||||
*/
|
||||
private $validator;
|
||||
|
||||
/**
|
||||
* PermissionsGroupController constructor.
|
||||
*
|
||||
@@ -50,18 +56,21 @@ class PermissionsGroupController extends AbstractController
|
||||
* @param RoleProvider $roleProvider
|
||||
* @param RoleHierarchy $roleHierarchy
|
||||
* @param TranslatorInterface $translator
|
||||
* @param ValidatorInterface $validator
|
||||
*/
|
||||
public function __construct(
|
||||
TranslatableStringHelper $translatableStringHelper,
|
||||
RoleProvider $roleProvider,
|
||||
RoleHierarchy $roleHierarchy,
|
||||
TranslatorInterface $translator
|
||||
TranslatorInterface $translator,
|
||||
ValidatorInterface $validator
|
||||
)
|
||||
{
|
||||
$this->translatableStringHelper = $translatableStringHelper;
|
||||
$this->roleProvider = $roleProvider;
|
||||
$this->roleHierarchy = $roleHierarchy;
|
||||
$this->translator = $translator;
|
||||
$this->validator = $validator;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -452,7 +461,7 @@ class PermissionsGroupController extends AbstractController
|
||||
);
|
||||
|
||||
$permissionsGroup->addRoleScope($roleScope);
|
||||
$violations = $this->get('validator')->validate($permissionsGroup);
|
||||
$violations = $this->validator->validate($permissionsGroup);
|
||||
|
||||
if ($violations->count() === 0) {
|
||||
$em->flush();
|
||||
|
@@ -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