Commit fcdcc8ed authored by dj3c1t's avatar dj3c1t

fix deprecations

parent b09d285d
......@@ -6,13 +6,15 @@ use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Form\FormError;
use Dj3c1t\AppBundle\Form\Type\UserType;
class ConfigurationController extends Controller {
public function indexAction(Request $request) {
$user = $this->getUser();
$oldPassword = $user->getPassword();
$form = $this->createForm(
"dj3c1t_user",
UserType::class,
$user,
array(
'validation_groups' => array("edit")
......
......@@ -7,6 +7,7 @@ use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Form\FormError;
use Dj3c1t\AppBundle\Entity\User;
use Dj3c1t\AppBundle\Form\Type\UserType;
class UserController extends Controller {
......@@ -33,7 +34,7 @@ class UserController extends Controller {
$user = new User();
$user->setIsActive(true);
$form = $this->createForm(
"dj3c1t_user",
UserType::class,
$user,
array(
'withAdminFields' => true,
......@@ -67,7 +68,7 @@ class UserController extends Controller {
public function editAction(Request $request, User $user) {
$oldPassword = $user->getPassword();
$form = $this->createForm(
"dj3c1t_user",
UserType::class,
$user,
array(
'validation_groups' => array("edit"),
......
......@@ -24,6 +24,5 @@ class Dj3c1tAppExtension extends Extension
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('services.yml');
$loader->load('services.forms.yml');
}
}
......@@ -8,6 +8,11 @@ use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\PropertyAccess\PropertyAccess;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\RepeatedType;
use Symfony\Component\Form\Extension\Core\Type\PasswordType;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Doctrine\ORM\EntityRepository;
class UserType extends AbstractType implements DataMapperInterface {
......@@ -22,14 +27,14 @@ class UserType extends AbstractType implements DataMapperInterface {
$builder->setDataMapper($this);
$builder->add(
'username',
'text',
TextType::class,
array(
'label' => 'Login'
)
);
$builder->add(
'email',
'text',
TextType::class,
array(
'label' => 'Email'
)
......@@ -37,7 +42,7 @@ class UserType extends AbstractType implements DataMapperInterface {
if($options["withAdminFields"]) {
$builder->add(
'roles',
'entity',
EntityType::class,
array(
'label' => 'Roles',
'class' => 'Dj3c1tAppBundle:Role',
......@@ -49,7 +54,7 @@ class UserType extends AbstractType implements DataMapperInterface {
}
$builder->add(
'changePassword',
'checkbox',
CheckboxType::class,
array(
'mapped' => false,
'label' => 'Change password',
......@@ -58,9 +63,9 @@ class UserType extends AbstractType implements DataMapperInterface {
);
$builder->add(
'password',
'repeated',
RepeatedType::class,
array(
'type' => 'password',
'type' => PasswordType::class,
'invalid_message' => 'The password fields must match',
'first_options' => array('label' => 'Password'),
'second_options' => array('label' => 'Password (confirm)'),
......@@ -69,7 +74,7 @@ class UserType extends AbstractType implements DataMapperInterface {
if($options["withAdminFields"]) {
$builder->add(
'isActive',
'checkbox',
CheckboxType::class,
array(
'label' => 'Active account'
)
......@@ -77,10 +82,6 @@ class UserType extends AbstractType implements DataMapperInterface {
}
}
public function getName() {
return 'dj3c1t_user';
}
public function configureOptions(OptionsResolver $resolver) {
$resolver->setDefaults(
array(
......
services:
dj3c1t.form.type.user:
class: Dj3c1t\AppBundle\Form\Type\UserType
tags:
- { name: form.type, alias: dj3c1t_user }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment