example-modules
example-modules copied to clipboard
ClassNotFoundException ; Attempted to load class LegacyLayout from the global namespace
When I try to create a new quote in demodoctrine I get the following error:
Attempted to load class "LegacyLayout" from the global namespace. Did you forget a "use" statement?
CRITICAL20:22:59 | php | Class 'LegacyLayout' not found CRITICAL20:22:59 | request | Uncaught PHP Exception Symfony\Component\Debug\Exception\ClassNotFoundException: "Attempted to load class "LegacyLayout" from the global namespace. Did you forget a "use" statement?" at /var/www/prestashop/classes/controller/AdminController.php line 3674
Thanks a lot.
Same issue here. I'm also trying to create my own module using demodoctrine as a model, and I get the same error.
This is the stack trace for my module:
Symfony\Component\Debug\Exception\ClassNotFoundException:
Attempted to load class "LegacyLayout" from the global namespace.
Did you forget a "use" statement?
at classes\controller\AdminController.php:3674
at AdminControllerCore->validateRules()
(classes\controller\AdminController.php:1170)
at AdminControllerCore->processAdd()
(classes\controller\AdminController.php:981)
at AdminControllerCore->postProcess()
(classes\controller\Controller.php:295)
at ControllerCore->run()
(src\Adapter\LegacyContext.php:240)
at PrestaShop\PrestaShop\Adapter\LegacyContext->getLegacyLayout('AdminRetailersmapGroups', '', array(), '', true, '', false, '', array('base_url' => '/admin374taf1hz/index.php', 'token' => 'VuUyVsBOLcbKq24QzAOGJ-5WPXDvL_b8Z71AZHppIus'), '', true)
(src\PrestaShopBundle\Twig\LayoutExtension.php:206)
at PrestaShopBundle\Twig\LayoutExtension->getLegacyLayout('AdminRetailersmapGroups', '', array(), '', true, '', false, '', array('base_url' => '/admin374taf1hz/index.php', 'token' => 'VuUyVsBOLcbKq24QzAOGJ-5WPXDvL_b8Z71AZHppIus'), '', true)
(var\cache\dev\twig\81\81a1b52507b41cc8f61a6ee6825db41672b392967f63ec166704882f4e14b78a.php:42)
at __TwigTemplate_5a423c1fb1b3c4a4739402c229f3c453599208bfd88ee3ff538b876b259849ff->doGetParent(array('groupForm' => object(FormView), 'theme' => object(Theme), 'default_currency' => '€', 'root_url' => '/', 'js_translatable' => array(), 'app' => object(AppVariable), 'webpack_server' => false, 'ps' => object(__TwigTemplate_11fa9b76aef4cbb57f844945f48d9295b55e0854c6e849f1360cf2714778f898)))
(vendor\twig\twig\src\Template.php:127)
at Twig\Template->getParent(array('groupForm' => object(FormView), 'theme' => object(Theme), 'default_currency' => '€', 'root_url' => '/', 'js_translatable' => array(), 'app' => object(AppVariable), 'webpack_server' => false, 'ps' => object(__TwigTemplate_11fa9b76aef4cbb57f844945f48d9295b55e0854c6e849f1360cf2714778f898)))
(var\cache\dev\twig\81\81a1b52507b41cc8f61a6ee6825db41672b392967f63ec166704882f4e14b78a.php:56)
at __TwigTemplate_5a423c1fb1b3c4a4739402c229f3c453599208bfd88ee3ff538b876b259849ff->doDisplay(array('groupForm' => object(FormView), 'theme' => object(Theme), 'default_currency' => '€', 'root_url' => '/', 'js_translatable' => array(), 'app' => object(AppVariable), 'webpack_server' => false, 'ps' => object(__TwigTemplate_11fa9b76aef4cbb57f844945f48d9295b55e0854c6e849f1360cf2714778f898)), array('javascripts' => array(object(__TwigTemplate_5a423c1fb1b3c4a4739402c229f3c453599208bfd88ee3ff538b876b259849ff), 'block_javascripts'), 'translate_javascripts' => array(object(__TwigTemplate_5a423c1fb1b3c4a4739402c229f3c453599208bfd88ee3ff538b876b259849ff), 'block_translate_javascripts'), 'content_header' => array(object(__TwigTemplate_5a423c1fb1b3c4a4739402c229f3c453599208bfd88ee3ff538b876b259849ff), 'block_content_header'), 'sidebar_right' => array(object(__TwigTemplate_5a423c1fb1b3c4a4739402c229f3c453599208bfd88ee3ff538b876b259849ff), 'block_sidebar_right'), 'content' => array(object(__TwigTemplate_03a1b76a50d403e612871e8098c1359e46f6cf8ba1d8088b30c81812139f4940), 'block_content')))
(vendor\twig\twig\src\Template.php:455)
at Twig\Template->displayWithErrorHandling(array('groupForm' => object(FormView), 'theme' => object(Theme), 'default_currency' => '€', 'root_url' => '/', 'js_translatable' => array(), 'app' => object(AppVariable), 'webpack_server' => false), array('javascripts' => array(object(__TwigTemplate_5a423c1fb1b3c4a4739402c229f3c453599208bfd88ee3ff538b876b259849ff), 'block_javascripts'), 'translate_javascripts' => array(object(__TwigTemplate_5a423c1fb1b3c4a4739402c229f3c453599208bfd88ee3ff538b876b259849ff), 'block_translate_javascripts'), 'content_header' => array(object(__TwigTemplate_5a423c1fb1b3c4a4739402c229f3c453599208bfd88ee3ff538b876b259849ff), 'block_content_header'), 'sidebar_right' => array(object(__TwigTemplate_5a423c1fb1b3c4a4739402c229f3c453599208bfd88ee3ff538b876b259849ff), 'block_sidebar_right'), 'content' => array(object(__TwigTemplate_03a1b76a50d403e612871e8098c1359e46f6cf8ba1d8088b30c81812139f4940), 'block_content')))
(vendor\twig\twig\src\Template.php:422)
at Twig\Template->display(array('groupForm' => object(FormView), 'theme' => object(Theme), 'default_currency' => '€', 'root_url' => '/', 'js_translatable' => array(), 'app' => object(AppVariable), 'webpack_server' => false), array('content' => array(object(__TwigTemplate_03a1b76a50d403e612871e8098c1359e46f6cf8ba1d8088b30c81812139f4940), 'block_content')))
(var\cache\dev\twig\59\596d10e3ee60edd293471b687e926362a9e18fab9d6f747447a6fee71545f51b.php:41)
at __TwigTemplate_03a1b76a50d403e612871e8098c1359e46f6cf8ba1d8088b30c81812139f4940->doDisplay(array('groupForm' => object(FormView), 'theme' => object(Theme), 'default_currency' => '€', 'root_url' => '/', 'js_translatable' => array(), 'app' => object(AppVariable), 'webpack_server' => false), array('content' => array(object(__TwigTemplate_03a1b76a50d403e612871e8098c1359e46f6cf8ba1d8088b30c81812139f4940), 'block_content')))
(vendor\twig\twig\src\Template.php:455)
at Twig\Template->displayWithErrorHandling(array('groupForm' => object(FormView), 'theme' => object(Theme), 'default_currency' => '€', 'root_url' => '/', 'js_translatable' => array(), 'app' => object(AppVariable), 'webpack_server' => false), array('content' => array(object(__TwigTemplate_03a1b76a50d403e612871e8098c1359e46f6cf8ba1d8088b30c81812139f4940), 'block_content')))
(vendor\twig\twig\src\Template.php:422)
at Twig\Template->display(array('groupForm' => object(FormView)))
(vendor\twig\twig\src\Template.php:434)
at Twig\Template->render(array('groupForm' => object(FormView)))
(vendor\symfony\symfony\src\Symfony\Bridge\Twig\TwigEngine.php:50)
at Symfony\Bridge\Twig\TwigEngine->render('@Modules/retailersmap/views/templates/admin/create.html.twig', array('groupForm' => object(FormView)))
(vendor\symfony\symfony\src\Symfony\Bundle\FrameworkBundle\Controller\ControllerTrait.php:286)
at Symfony\Bundle\FrameworkBundle\Controller\Controller->render('@Modules/retailersmap/views/templates/admin/create.html.twig', array('groupForm' => object(FormView)))
(modules\retailersmap\src\Controller\RetailersMapAdminGroupsController.php:64)
at PrestaShop\Module\RetailersMap\Controller\RetailersMapAdminGroupsController->createAction(object(Request))
(vendor\symfony\symfony\src\Symfony\Component\HttpKernel\HttpKernel.php:151)
at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(Request), 1)
(vendor\symfony\symfony\src\Symfony\Component\HttpKernel\HttpKernel.php:68)
at Symfony\Component\HttpKernel\HttpKernel->handle(object(Request), 1, false)
(vendor\symfony\symfony\src\Symfony\Component\HttpKernel\Kernel.php:200)
at Symfony\Component\HttpKernel\Kernel->handle(object(Request), 1, false)
(admin374taf1hz\index.php:82)
I have same problem and error. I have clean new install Prestashop 1.7.7.1 on php 7.3.27. I try to correct entity tablang, but without success (Fix tab entity tabLangs variable mapping #21218)
Hi @dvyvoj @dlabarta and @darioscattolini I'm sorry but I just tried, and demodoctrine works well for me.
If you can send a ZIP of your module I could try to see what is the issue, but for me it works good
What I do
- Install demodoctrine module following README instructions
- Go on BO, open Modules page, click "configure"
- Add quotes, see them, then generate quotes
- Go on FO homepage to see quotes displaued
I have mysql 8. Installation also failed, i need corect sql script - add semicolon at end of statement. After this, install ok. Can be problem in mysql version?
Hello, I've Same problem when I tried to add quotes (in demodoctrine module)
Version 1.7.7.4 I think It's rather system problem than developper problem
Is anyone find solution please or please help me to understand where come from the problem ?
probably my dev environment ? Prestashop 1.7.7.4 /mysql with docker Ubuntu 20.04 from WSL2 with php-7.3
EDIT
there is a probably problem when I installed Symfony 3.4 ( Which I understood the version needed ) , the command line isn't available I rather ask help in another place, this is not a problem with this demo module
EDIT 2
I install a linux dev environment , ubuntu/docker ... I make a mistake somewhere, sure ... same problem appears on demodoctrine module
@matks could you give me some informations about your Dev environnment please ? to compare what I do bad ?
Thanks Regards
@dlabarta , @darioscattolini , do you solve your problem please ?
Same problem here, on Windows, clean PrestaShop 1.7.7.4 installation.
Same problem on Mac :) , with mamp ( test on 1.7.7.4, 1.7.7.1, 1.7.7.0 ) php7.3, Mysql 5.7
I don't understand ...
please help ? regards
Next step ...
I think I found a bot of solution when I Generate Quotes ( part of module which run directly )
There is a diderot's quote which says :
"On n'est point toujours une bête pour l'avoir été quelquefois...."
Ce fut une révélation ... Bref...
In routes.yml , some routes add a default : _legacy_controller AdminDemodoctrineQuote which not exists so probably LegacyLaout class Cry when she not founds legacy controller ...
when commenting this lines (for quote_create road) , it runs ...
I don't know for the moment why quote_index road runs directly (like delete) enough commenting legacy_controller road ...
I have mysql 8. Installation also failed, i need corect sql script - add semicolon at end of statement. After this, install ok. Can be problem in mysql version?
I dont think the install and this error are related :/
I got the same problem ... ` ClassNotFoundException
Symfony\Component\Debug\Exception\ClassNotFoundException: Attempted to load class "LegacyLayout" from the global namespace. Did you forget a "use" statement? at classes/ObjectModel.php:2036 at ObjectModelCore::getDefinition('LegacyLayout') (classes/controller/AdminController.php:868) at AdminControllerCore->processFilter() (classes/controller/AdminController.php:968) at AdminControllerCore->postProcess() (classes/controller/Controller.php:295) at ControllerCore->run() (src/Adapter/LegacyContext.php:242) at PrestaShop\PrestaShop\Adapter\LegacyContext->getLegacyLayout('AdminPerformance', 'Performances', array('clear_cache' => array('href' => '/serverarianeplast/admin198uhbdmj/index.php/configure/advanced/performance/clear-cache?_token=UhpEIgPFKIyuXTgM9kgtNcPi6KgFGzd_xu27GmPKhrQ', 'desc' => 'Vider le cache', 'icon' => 'delete')), '', true, '', true, `
I don't know how to resolve it. This error appears when I want to go to the module page
Hello,
I'm facing the same issue and I've fixed that one by changing the PHP version on my webserver. The issue was resolved by using an "older" PHP version (7.3 instead of 7.4) but before this I have disabled all the plugins from the database by porting the "active" field all to zero.
Hope this helps.
Hello, I have the same problem. I created an admin module. After I make a search, causing cookies to be changed, the standard products list page does not work anymore.
Please help!
After a wild ride in the Prestashop/Symfony core I finally found a solution to make the demodoctrine module work :
- Open
demodoctrine/config/routes.yml
and look for :_legacy_link: 'AdminDemodoctrineQuote:update'
on line 40 - Change
AdminDemodoctrineQuote:update
toAdminDemodoctrineQuote:edit
- Voilà ! 🚀
In case someone has this issue, it's a cookie trouble. Clear all cookies and data from domain fixe it.
Thanks for the tips @kvnbra & @ComonSoft ! I'm closing this ticket :)