Browse Source

Refactoring actions

packProduct
Fab 3 years ago
parent
commit
8de8b42043
2 changed files with 12 additions and 8 deletions
  1. +6
    -4
      Controller/Credit/CreditHistoryAdminController.php
  2. +6
    -4
      Controller/User/UserMerchantAdminController.php

+ 6
- 4
Controller/Credit/CreditHistoryAdminController.php View File

@@ -32,12 +32,14 @@ abstract class CreditHistoryAdminController extends AbstractAdminController

protected $em;
protected $translatorAdmin;
public function __construct(EntityManagerInterface $entityManager, TranslatorAdmin $translatorAdmin){

public function __construct(EntityManagerInterface $entityManager, TranslatorAdmin $translatorAdmin)
{
$this->em = $entityManager;
$this->translatorAdmin = $translatorAdmin;
}

public function overrideGlobalActions(?ActionCollection $actions)
public function overrideGlobalActions(?ActionCollection $actions): void
{
parent::overrideGlobalActions($actions);
if ($actions) {
@@ -84,7 +86,7 @@ abstract class CreditHistoryAdminController extends AbstractAdminController
{
$crud->overrideTemplate('crud/index', '@LcCaracole/admin/credit/credit_history_index.html.twig');

return $crud ;
return $crud;
}

public function configureFields(string $pageName): iterable
@@ -130,7 +132,7 @@ abstract class CreditHistoryAdminController extends AbstractAdminController
$this->translatorAdmin->transField(
'meanPaymentOptions.'.CreditHistoryModel::MEAN_PAYMENT_TRANSFER,
'CreditHistory'
) => CreditHistoryModel::MEAN_PAYMENT_TRANSFER
) => CreditHistoryModel::MEAN_PAYMENT_TRANSFER,
)
);;
yield TextField::new('reference');

+ 6
- 4
Controller/User/UserMerchantAdminController.php View File

@@ -33,15 +33,18 @@ use Symfony\Component\HttpFoundation\Response;
abstract class UserMerchantAdminController extends AbstractAdminController
{
use AdminControllerTrait;

protected $em;
protected $translatorAdmin;

public function __construct(EntityManagerInterface $entityManager, TranslatorAdmin $translatorAdmin){
public function __construct(EntityManagerInterface $entityManager, TranslatorAdmin $translatorAdmin)
{
$this->em = $entityManager;
$this->translatorAdmin = $translatorAdmin;
}

public function overrideEntitiesActions(?EntityCollection $entities){
public function overrideEntitiesActions(?EntityCollection $entities): void
{
$context = $this->get(AdminContextProvider::class)->getContext();
$adminUrlGenerator = $this->get(AdminUrlGenerator::class);

@@ -49,7 +52,7 @@ abstract class UserMerchantAdminController extends AbstractAdminController
$this->em->getEntityName(CreditHistoryInterface::class)
);

if($entities) {
if ($entities) {
foreach ($entities as $entity) {
foreach ($entity->getActions() as $action) {
if ($action->getName('credit_history')) {
@@ -108,7 +111,6 @@ abstract class UserMerchantAdminController extends AbstractAdminController
$form->handleRequest($context->getRequest());

if ($form->isSubmitted() && $form->isValid()) {

$userMerchant = $form->getData();

$existingUser = $userRepository->findOneByEmail($form->get('email')->getData());

Loading…
Cancel
Save