소스 검색

Merge branch 'develop'

tags/0.1
Guillaume 3 년 전
부모
커밋
c19c6bbc71
6개의 변경된 파일46개의 추가작업 그리고 36개의 파일을 삭제
  1. +2
    -2
      Controller/Admin/UserController.php
  2. +5
    -4
      Form/Type/User/ChangePasswordFormType.php
  3. +12
    -23
      Form/Type/User/ProfileFormType.php
  4. +13
    -1
      Resources/translations/admin.fr.yaml
  5. +4
    -2
      Resources/views/adminlte/crud/form_theme.html.twig
  6. +10
    -4
      Translation/TranslatorAdmin.php

+ 2
- 2
Controller/Admin/UserController.php 파일 보기

@@ -3,6 +3,7 @@
namespace Lc\SovBundle\Controller\Admin;

use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto;
use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProvider;
use Lc\SovBundle\Doctrine\EntityManager;
use Lc\SovBundle\Form\Type\User\ChangePasswordFormType;
use Lc\SovBundle\Form\Type\User\ProfileFormType;
@@ -14,7 +15,6 @@ use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;

class UserController extends AbstractController
{

protected $em;

public function __construct(EntityManager $em)
@@ -54,7 +54,7 @@ class UserController extends AbstractController
if ($form->isSubmitted() && $form->isValid()) {
$user = $form->getData();

$plainPassword = $form->get('plainPassword')->getData();
$plainPassword = $form->get('plain_password')->getData();

// @TODO : créer UserManager
$newPasswordEncoded = $passwordEncoder->encodePassword($user, $plainPassword);

+ 5
- 4
Form/Type/User/ChangePasswordFormType.php 파일 보기

@@ -20,6 +20,7 @@ use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Security\Core\Validator\Constraints\UserPassword;
use Symfony\Component\Translation\TranslatableMessage;
use Symfony\Component\Validator\Constraints\NotBlank;

class ChangePasswordFormType extends AbstractType
@@ -49,7 +50,7 @@ class ChangePasswordFormType extends AbstractType
'current_password',
PasswordType::class,
[
'label' => 'Mot de passe actuel',
'label' => 'form.change_password.current_password',
'mapped' => false,
'constraints' => [
new NotBlank(),
@@ -64,8 +65,8 @@ class ChangePasswordFormType extends AbstractType
[
'type' => PasswordType::class,
'mapped' => false,
'first_options' => ['label' => 'Nouveau mot de passe'],
'second_options' => ['label' => 'Nouveau mot de passe (confirmation)'],
'first_options' => ['label' => 'form.change_password.new_password'],
'second_options' => ['label' => 'form.change_password.new_password_repeat'],
'invalid_message' => 'Les deux mots de passe ne correspondent pas.',
]
);
@@ -74,7 +75,7 @@ class ChangePasswordFormType extends AbstractType
'submit',
SubmitType::class,
array(
'label' => 'Sauvegarder'
'label' => new TranslatableMessage('action.save', [], 'admin')
)
);
}

+ 12
- 23
Form/Type/User/ProfileFormType.php 파일 보기

@@ -12,60 +12,49 @@ use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Translation\TranslatableMessage;

class ProfileFormType extends AbstractType
{
protected $em ;
protected $em;

public function __construct(EntityManager $em)
{
$this->em = $em ;
$this->em = $em;
}

public function buildForm(FormBuilderInterface $builder, array $options)
{
$entityName = $this->em->getEntityName(UserInterface::class) ;
$entityName = $this->em->getEntityName(UserInterface::class);

$builder->add(
'firstname',
TextType::class,
array(
'label' => 'Prénom'
)
TextType::class
);

$builder->add(
'lastname',
TextType::class,
array(
'label' => 'Nom'
)
TextType::class
);

$builder->add(
'email',
EmailType::class,
array(
'label' => 'Email'
)
EmailType::class
);

if(property_exists($entityName, 'phone')) {
if (property_exists($entityName, 'phone')) {
$builder->add(
'phone',
TextType::class,
array(
'label' => 'Téléphone'
)
TextType::class
);
}

$builder->add(
'submit',
SubmitType::class,
array(
'label' => 'Sauvegarder'
)
[
'label' => new TranslatableMessage('action.save', [], 'admin')
]
);
}


+ 13
- 1
Resources/translations/admin.fr.yaml 파일 보기

@@ -31,6 +31,9 @@ entity:
user:
label: Utilisateur
label_plurial: Utilisateurs
fields:
firstname: Prénom
lastname: Nom
page:
label: Page
label_plurial: Pages
@@ -48,4 +51,13 @@ entity:
general: Général
configuration: Configuration
gallery: Galerie
seo: Référencement
seo: Référencement

action:
save: Sauvegarder

form:
change_password:
current_password: Mot de passe actuel
new_password: Nouveau mot de passe
new_password_repeat: Nouveau mot de passe (confirmer)

+ 4
- 2
Resources/views/adminlte/crud/form_theme.html.twig 파일 보기

@@ -43,7 +43,7 @@
</div>
{% endif %}

{% set help_message = name|lc_trans_admin_help(ea.getEntity().getFqcn()) %}
{% set help_message = name|lc_trans_admin_help(form.parent.vars.data) %}
{% if help_message != '' %}
<small class="form-help">{{ help_message }}</small>
{% endif %}
@@ -77,7 +77,9 @@
{%- endif -%}
{%- endif -%}

<{{ element|default('label') }}{% if label_attr %}{% with { attr: label_attr } %}{{ block('attributes') }}{% endwith %}{% endif %}>{{ (translation_domain is same as(false)) ? label : label|lower|lc_trans_admin_field(ea.getEntity().getFqcn()) }}</{{ element|default('label') }}>
{# <{{ element|default('label') }}{% if label_attr %}{% with { attr: label_attr } %}{{ block('attributes') }}{% endwith %}{% endif %}>{{ (translation_domain is same as(false)) ? label : label|lower|lc_trans_admin_field(ea.getEntity().getFqcn()) }}</{{ element|default('label') }}> #}
<{{ element|default('label') }}{% if label_attr %}{% with { attr: label_attr } %}{{ block('attributes') }}{% endwith %}{% endif %}>{{ (label is not empty and '.' in label) ? label|trans({}, 'admin') : name|lc_trans_admin_field(form.parent.vars.data) }}</{{ element|default('label') }}>

{%- endif -%}
{%- endblock form_label %}


+ 10
- 4
Translation/TranslatorAdmin.php 파일 보기

@@ -105,8 +105,6 @@ class TranslatorAdmin
$entityName = $this->getEntityName($entityClass);
}



return 'entity.' . $entityName . '.panels.' . $panelName;
}

@@ -117,8 +115,16 @@ class TranslatorAdmin

private function getEntityName($entityClass): string
{
$entityNameExplode = explode('\\', $entityClass);
return strtolower($entityNameExplode[count($entityNameExplode) - 1]);
if(is_object($entityClass)) {
$entityClass = get_class($entityClass) ;
}

if(is_string($entityClass)) {
$entityNameExplode = explode('\\', $entityClass);
return strtolower($entityNameExplode[count($entityNameExplode) - 1]);
}

return 'default' ;
}
}


Loading…
취소
저장