Browse Source

Refactoring dossiers controllers et form

feature/ticket
Guillaume 3 years ago
parent
commit
533735fc2d
13 changed files with 48 additions and 45 deletions
  1. +2
    -2
      Controller/AbstractAdminController.php
  2. +0
    -20
      Controller/Admin/UserCrudController.php
  3. +1
    -1
      Controller/Dashboard/DashboardController.php
  4. +1
    -1
      Controller/Security/SecurityController.php
  5. +18
    -0
      Controller/User/UserAdminController.php
  6. +1
    -1
      Controller/User/UserController.php
  7. +16
    -11
      Form/Common/CrudFormType.php
  8. +1
    -1
      Form/Common/FileManagerType.php
  9. +1
    -1
      Form/Common/PositionType.php
  10. +1
    -1
      Form/User/ChangePasswordFormType.php
  11. +1
    -1
      Form/User/ProfileFormType.php
  12. +4
    -4
      Resources/config/routes.yaml
  13. +1
    -1
      Resources/config/services.yaml

Controller/Admin/AbstractCrudController.php → Controller/AbstractAdminController.php View File

@@ -1,6 +1,6 @@
<?php

namespace Lc\SovBundle\Controller\Admin;
namespace Lc\SovBundle\Controller;

use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\QueryBuilder;
@@ -48,7 +48,7 @@ use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpFoundation\Session\SessionInterface;


abstract class AbstractCrudController extends EaAbstractCrudController
abstract class AbstractAdminController extends EaAbstractCrudController
{
protected $session;
protected $request;

+ 0
- 20
Controller/Admin/UserCrudController.php View File

@@ -1,20 +0,0 @@
<?php

namespace Lc\SovBundle\Controller\Admin;

use EasyCorp\Bundle\EasyAdminBundle\Config\Action;
use EasyCorp\Bundle\EasyAdminBundle\Config\Actions;
use EasyCorp\Bundle\EasyAdminBundle\Config\Crud;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;

abstract class UserCrudController extends AbstractCrudController
{

public function configureFields(string $pageName): iterable
{
return [
TextField::new('email')
];
}

}

Controller/Admin/DashboardController.php → Controller/Dashboard/DashboardController.php View File

@@ -1,6 +1,6 @@
<?php

namespace Lc\SovBundle\Controller\Admin;
namespace Lc\SovBundle\Controller\Dashboard;

use EasyCorp\Bundle\EasyAdminBundle\Config\Assets;
use EasyCorp\Bundle\EasyAdminBundle\Config\Crud;

Controller/Admin/SecurityController.php → Controller/Security/SecurityController.php View File

@@ -1,6 +1,6 @@
<?php

namespace Lc\SovBundle\Controller\Admin;
namespace Lc\SovBundle\Controller\Security;

use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;

+ 18
- 0
Controller/User/UserAdminController.php View File

@@ -0,0 +1,18 @@
<?php

namespace Lc\SovBundle\Controller\User;

use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
use Lc\SovBundle\Controller\AbstractAdminController;

abstract class UserAdminController extends AbstractAdminController
{

public function configureFields(string $pageName): iterable
{
return [
TextField::new('email')
];
}

}

Controller/Admin/UserController.php → Controller/User/UserController.php View File

@@ -1,6 +1,6 @@
<?php

namespace Lc\SovBundle\Controller\Admin;
namespace Lc\SovBundle\Controller\User;

use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto;
use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProvider;

Form/Type/Crud/CrudFormType.php → Form/Common/CrudFormType.php View File

@@ -1,6 +1,6 @@
<?php

namespace Lc\SovBundle\Form\Type\Crud;
namespace Lc\SovBundle\Form\Common;


use EasyCorp\Bundle\EasyAdminBundle\Form\Type\EaFormPanelType;
@@ -22,18 +22,20 @@ class CrudFormType extends AbstractType

protected $parent;
protected $doctrineOrmTypeGuesser;
public function __construct(DoctrineOrmTypeGuesser $doctrineOrmTypeGuesser, \EasyCorp\Bundle\EasyAdminBundle\Form\Type\CrudFormType $crudFormType)
{

public function __construct(
DoctrineOrmTypeGuesser $doctrineOrmTypeGuesser,
\EasyCorp\Bundle\EasyAdminBundle\Form\Type\CrudFormType $crudFormType
) {
$this->parent = $crudFormType;
$this->doctrineOrmTypeGuesser = $doctrineOrmTypeGuesser;

}

public function buildForm(FormBuilderInterface $builder, array $options)
{
$this->parent->buildForm($builder, $options);
$entityDto = $options['entityDto'];
$formPanels=[];
$formPanels = [];
$currentFormPanel = 0;
foreach ($entityDto->getFields() as $fieldDto) {
if (null === $formFieldType = $fieldDto->getFormType()) {
@@ -50,7 +52,7 @@ class CrudFormType extends AbstractType
'help' => $fieldDto->getHelp(),
'css_class' => $fieldDto->getCssClass(),
];
foreach($fieldDto->getCustomOptions()->all() as $customOptionKey=> $customOption){
foreach ($fieldDto->getCustomOptions()->all() as $customOptionKey => $customOption) {
$formPanels[$currentFormPanel][$customOptionKey] = $customOption;
}
continue;
@@ -60,17 +62,20 @@ class CrudFormType extends AbstractType
//$this->niche->buildForm($builder, $options);
}

public function finishView(FormView $view, FormInterface $form, array $options){
public function finishView(FormView $view, FormInterface $form, array $options)
{
$this->parent->finishView($view, $form, $options);
}
public function configureOptions(OptionsResolver $resolver){
$this->parent->configureOptions($resolver);

public function configureOptions(OptionsResolver $resolver)
{
$this->parent->configureOptions($resolver);
}
public function getBlockPrefix(){

public function getBlockPrefix()
{
return $this->parent->getBlockPrefix();
}



}

Form/Type/Crud/FileManagerType.php → Form/Common/FileManagerType.php View File

@@ -1,6 +1,6 @@
<?php

namespace Lc\SovBundle\Form\Type\Crud;
namespace Lc\SovBundle\Form\Common;

use Lc\SovBundle\DataTransformer\FileManagerTypeToDataTransformer;
use Lc\SovBundle\Entity\File\File;

Form/Type/Crud/PositionType.php → Form/Common/PositionType.php View File

@@ -1,6 +1,6 @@
<?php

namespace Lc\SovBundle\Form\Type\Crud;
namespace Lc\SovBundle\Form\Common;


use Symfony\Component\Form\AbstractType;

Form/Type/User/ChangePasswordFormType.php → Form/User/ChangePasswordFormType.php View File

@@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

namespace Lc\SovBundle\Form\Type\User;
namespace Lc\SovBundle\Form\User;

use Lc\SovBundle\Doctrine\EntityManager;
use Lc\SovBundle\Model\User\UserInterface;

Form/Type/User/ProfileFormType.php → Form/User/ProfileFormType.php View File

@@ -1,6 +1,6 @@
<?php

namespace Lc\SovBundle\Form\Type\User;
namespace Lc\SovBundle\Form\User;

use Lc\SovBundle\DataTransformer\FileManagerTypeToDataTransformer;
use Lc\SovBundle\Doctrine\EntityManager;

+ 4
- 4
Resources/config/routes.yaml View File

@@ -8,17 +8,17 @@ artgris_bundle_file_manager:

sov_login:
path: /login
controller: Lc\SovBundle\Controller\Admin\SecurityController::login
controller: Lc\SovBundle\Controller\Security\SecurityController::login

sov_logout:
path: /logout
controller: Lc\SovBundle\Controller\Admin\SecurityController::logout
controller: Lc\SovBundle\Controller\Security\SecurityController::logout

sov_admin_account_profile:
path: /admin/account/profile
controller: Lc\SovBundle\Controller\Admin\UserController::profile
controller: Lc\SovBundle\Controller\User\UserController::profile

sov_admin_account_password:
path: /admin/account/password
controller: Lc\SovBundle\Controller\Admin\UserController::changePassword
controller: Lc\SovBundle\Controller\User\UserController::changePassword


+ 1
- 1
Resources/config/services.yaml View File

@@ -15,7 +15,7 @@ services:
resource: '../../Controller/'
tags: [ 'controller.service_arguments' ]

Lc\SovBundle\Form\Type\Crud\CrudFormType:
Lc\SovBundle\Form\Common\CrudFormType:
decorates: EasyCorp\Bundle\EasyAdminBundle\Form\Type\CrudFormType
arguments: [ '@form.type_guesser.doctrine', '@.inner' ]


Loading…
Cancel
Save