fix constructor injection

This commit is contained in:
2025-11-03 18:05:31 +01:00
parent 662e962549
commit 2ca88d786c
2 changed files with 2 additions and 53 deletions

View File

@@ -16,7 +16,6 @@ use Chill\CustomFieldsBundle\Entity\CustomFieldsDefaultGroup;
use Chill\CustomFieldsBundle\Entity\CustomFieldsGroup;
use Chill\CustomFieldsBundle\Form\CustomFieldsGroupType;
use Chill\CustomFieldsBundle\Form\DataTransformer\CustomFieldsGroupToIdTransformer;
use Chill\CustomFieldsBundle\Form\Type\CustomFieldType as FormTypeCustomField;
use Chill\CustomFieldsBundle\Service\CustomFieldProvider;
use Doctrine\ORM\Query;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
@@ -40,7 +39,6 @@ class CustomFieldsGroupController extends AbstractController
private readonly CustomFieldProvider $customFieldProvider,
private readonly TranslatorInterface $translator,
private readonly \Doctrine\Persistence\ManagerRegistry $managerRegistry,
private readonly \Twig\Loader\FilesystemLoader $filesystemLoader,
private readonly \Symfony\Component\Form\FormFactoryInterface $formFactory,
) {}
@@ -181,55 +179,6 @@ class CustomFieldsGroupController extends AbstractController
]);
}
/**
* This function render the customFieldsGroup as a form.
*
* This function is for testing purpose !
*
* The route which call this action is not in Resources/config/routing.yml,
* but in Tests/Fixtures/App/app/config.yml
*
* @param int $id
*/
public function renderFormAction($id, Request $request): \Symfony\Component\HttpFoundation\Response
{
$em = $this->managerRegistry->getManager();
$entity = $em->getRepository(CustomFieldsGroup::class)->find($id);
if (null === $entity) {
throw $this->createNotFoundException('Unable to find CustomFieldsGroups entity.');
}
$form = $this->createForm(FormTypeCustomField::class, null, ['group' => $entity]);
$form->add('submit_dump', SubmitType::class, ['label' => 'POST AND DUMP']);
$form->add('submit_render', SubmitType::class, ['label' => 'POST AND RENDER']);
$form->handleRequest($request);
$this->filesystemLoader
->addPath(
__DIR__.'/../Tests/Fixtures/App/app/Resources/views/',
$namespace = 'test'
);
if ($form->isSubmitted()) {
if ($form->get('submit_render')->isClicked()) {
return $this->render('@ChillCustomFields/CustomFieldsGroup/render_for_test.html.twig', [
'fields' => $form->getData(),
'customFieldsGroup' => $entity,
]);
}
// dump($form->getData());
// dump(json_enccode($form->getData()));
}
return $this
->render('@test/CustomField/simple_form_render.html.twig', [
'form' => $form,
]);
}
/**
* Finds and displays a CustomFieldsGroup entity.
*/

View File

@@ -24,7 +24,7 @@ use Symfony\Component\Form\Extension\Core\Type\FormType;
use Symfony\Component\Form\Form;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
/**
@@ -41,7 +41,7 @@ class ReportController extends AbstractController
private readonly PaginatorFactory $paginator,
private readonly TranslatorInterface $translator,
private readonly \Doctrine\Persistence\ManagerRegistry $managerRegistry,
private readonly TokenStorage $tokenStorage,
private readonly TokenStorageInterface $tokenStorage,
private readonly \Symfony\Component\Form\FormFactoryInterface $formFactory,
) {}