Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ClassNotFoundException ; Attempted to load class LegacyLayout from the global namespace #42

Closed
dlabarta opened this issue Jan 29, 2021 · 16 comments

Comments

@dlabarta
Copy link

dlabarta commented Jan 29, 2021

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.

@darioscattolini
Copy link

darioscattolini commented Feb 9, 2021

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)

@dvyvoj
Copy link

dvyvoj commented Mar 14, 2021

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)

@matks
Copy link
Contributor

matks commented Mar 15, 2021

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

  1. Install demodoctrine module following README instructions
  2. Go on BO, open Modules page, click "configure"
  3. Add quotes, see them, then generate quotes
  4. Go on FO homepage to see quotes displaued

@dvyvoj
Copy link

dvyvoj commented Apr 9, 2021

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?

@NicolasG25
Copy link

NicolasG25 commented May 10, 2021

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

@NicolasG25
Copy link

@dlabarta , @darioscattolini , do you solve your problem please ?

@adrianogoncalves
Copy link

adrianogoncalves commented May 10, 2021

Same problem here, on Windows, clean PrestaShop 1.7.7.4 installation.

@NicolasG25
Copy link

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

@NicolasG25
Copy link

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 ...

@matks
Copy link
Contributor

matks commented May 14, 2021

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 :/

@william-dandrea
Copy link

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

@matks matks changed the title ClassNotFoundException ClassNotFoundException ; Attempted to load class LegacyLayout from the global namespace Jul 12, 2021
@UffTec
Copy link

UffTec commented Aug 5, 2021

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.

@sonnessa
Copy link

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!

@kvnbra
Copy link

kvnbra commented Aug 19, 2021

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 to AdminDemodoctrineQuote:edit
  • Voilà ! 🚀

@ComonSoft
Copy link

In case someone has this issue, it's a cookie trouble. Clear all cookies and data from domain fixe it.

@kpodemski
Copy link
Contributor

Thanks for the tips @kvnbra & @ComonSoft ! I'm closing this ticket :)

kpodemski added a commit to kpodemski/example-modules that referenced this issue Jun 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests