eureka2 / G6K

Generator of calculation simulator (calculator)
MIT License
20 stars 19 forks source link

Exception when I want to edit or test a simulator #37

Closed Dexter0015 closed 3 years ago

Dexter0015 commented 3 years ago

Hi,

After having installed g6k and the simulator "coût du certification d'immatriculation", I encouter the following issue:


Error: Call to protected method Symfony\Bundle\FrameworkBundle\Controller\AbstractController::getParameter() from context 'App\G6K\Model\Simulator'
at App.G6K.Model.Simulator.loadDatabases(Simulator.php:1909)
at App.G6K.Model.Simulator.loadEntities(Simulator.php:1567)
at App.G6K.Model.Simulator.load(Simulator.php:1526)
at App.G6K.Controller.SimulatorsAdminController.runIndex(SimulatorsAdminController.php:248)
at App.G6K.Controller.SimulatorsAdminController.index(SimulatorsAdminController.php:181)
at Symfony.Component.HttpKernel.HttpKernel.handleRaw(HttpKernel.php:158)
at Symfony.Component.HttpKernel.HttpKernel.handle(HttpKernel.php:80)
at Symfony.Component.HttpKernel.Kernel.handle(Kernel.php:201)
at (main)(admin.php:37)
#0 /var/www/vhosts/cartegrise24h.fr/api/src/G6K/Model/Simulator.php(1567): App\G6K\Model\Simulator->loadDatabases(Object(SimpleXMLElement))
#1 /var/www/vhosts/cartegrise24h.fr/api/src/G6K/Model/Simulator.php(1526): App\G6K\Model\Simulator->loadEntities(Object(SimpleXMLElement), Object(SimpleXMLElement))
#2 /var/www/vhosts/cartegrise24h.fr/api/src/G6K/Controller/SimulatorsAdminController.php(248): App\G6K\Model\Simulator->load('/var/www/vhosts...')
#3 /var/www/vhosts/cartegrise24h.fr/api/src/G6K/Controller/SimulatorsAdminController.php(181): App\G6K\Controller\SimulatorsAdminController->runIndex(Object(Symfony\Component\HttpFoundation\Request), 'cout-certificat...', NULL)
#4 /var/www/vhosts/cartegrise24h.fr/api/vendor/symfony/http-kernel/HttpKernel.php(158): App\G6K\Controller\SimulatorsAdminController->index(Object(Symfony\Component\HttpFoundation\Request), 'cout-certificat...', NULL)
#5 /var/www/vhosts/cartegrise24h.fr/api/vendor/symfony/http-kernel/HttpKernel.php(80): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
#6 /var/www/vhosts/cartegrise24h.fr/api/vendor/symfony/http-kernel/Kernel.php(201): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#7 /var/www/vhosts/cartegrise24h.fr/api/calcul/admin.php(37): Symfony\Component\HttpKernel\Kernel->handle(Object(Symfony\Component\HttpFoundation\Request))
#8 {main}

THe exception is displayed even in front or admin.

For information, I already have an older version of the API (Symfony 2 version) which is working on the same server. For this new installation, I created a neaw vhost, et a new database with associated user. The database is not called "cout_certificat_immatriculation", but "cout_immat" (to avoid overwriting the datas of the current running version).

The database connexion is ok, I was able to test it without any issue et btw, the datas are visible when I go to data source in the admin.

So I'm wondering is the issue isn't the link between the simulator and the data source. Where can I find this without using the admin as I can't load the simulator in it? Maybe through an xml file somewhere in the sources?

eureka2 commented 3 years ago

Hi,

Can you add these few lines in the 'ControllersTrait.php' file:

/ **
* {@inheritdoc}
* /
public function getParameter(string $name) {
    return parent::getParameter($name);
}

This will be fixed in the next version.

PS: Can you now ask your questions in English to respect the current uses on github?

Best regards

Dexter0015 commented 3 years ago

Thanks,

Unfortunately it didn't work, BUT I manage to make it work by changing the accessibility of the getParameter() method to public in AbstractController.php file.

Though I find it odd to change the core files of the symfony bundle...

P.S. : I updated my question, sorry for that.

Regards

eureka2 commented 3 years ago

Indeed it is a very bad idea to modify AbstractController.php.

It is better to add these lines in BaseController.php and BaseAdminController.php

/ **
* {@inheritdoc}
* /
public function getParameter(string $name) {
    return parent::getParameter($name);
}
Dexter0015 commented 3 years ago

I did the correction (revert my modification of the symfony bundle file and add this method to the correct controller) and it worked.

Add to add the method in ApiController.php too to avoid having the exception when requesting the API.