presta-dyr Posted March 4 Share Posted March 4 Hi, I have module a with an admin controller. I want to add some extra buttons to the order overview. The following works with PrestaShop 8: class GlsparcelController extends OrderController { public function __construct() { } public function myIndexAction(Request $request, OrderFilters $filters) { $filters->setFilterId('glsparcelOrder'); $orderKpiFactory = $this->container->get('prestashop.core.kpi_row.factory.orders'); $orderGrid = $this->container->get('prestashop.core.grid.factory.order')->getGrid($filters); $changeOrderStatusesForm = $this->createForm(ChangeOrdersStatusType::class); $bulkActions = new BulkActionCollection(); $bulkActions ->add( (new SubmitBulkAction('print_label')) ->setName('Print selected') ->setOptions([ 'submit_route' => 'glsparcel_orders_print', ]) ); $orderGrid->getDefinition()->setBulkActions($bulkActions); return $this->render( '@PrestaShop/Admin/Sell/Order/Order/index.html.twig', [ 'orderGrid' => $this->presentGrid($orderGrid), 'help_link' => $this->generateSidebarLink($request->attributes->get('_legacy_controller')), 'enableSidebar' => true, 'changeOrderStatusesForm' => $changeOrderStatusesForm->createView(), 'orderKpi' => $orderKpiFactory->build(), ] ); } } Unfortunately it fails in PrestaShop 9.0 with the message: The "form.factory" service or alias has been removed or inlined when the container was compiled. You should either make it public, or stop using the container directly and use dependency injection instead. I assume the problem is due to the new Symfony version. The service links to Symfony\Component\Form\FormFactory. Can this be solved? /Kjeld Link to comment Share on other sites More sharing options...
Webkul Solutions Posted May 8 Share Posted May 8 As, we have observed that in PS version 9, which uses Symfony 6.4, so, you need to inject the services you depend on, like FormFactoryInterface, in your controller constructor, like constructor-based dependency injection. use Symfony\Component\Form\FormFactoryInterface; public function __construct(private readonly FormFactoryInterface $formFactory) { } You can refer to the PS 9.x.x file 'src/PrestaShopBundle/Controller/Admin/Sell/Order/OrderController.php' or compare the same file with the PS8.x.x There you can find a way. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now