Comments (9)
It was I expected... But isn't work, for sure (it's why I have created this issue, because the old way doesn't seems to work there). ;-)
from docs.
Sorry we got a bit confused! Indeed the id
is extracted from the URL by the routing component but it isn't in $_GET
nor $_POST
. It's an attribute in the request.
Hence your snippet was the best way to achieve that, well done! :)
For reference:
global $kernel;
$request = $kernel->getContainer()->get('request');
$idProduct = $request->get('id');
from docs.
We are not supposed to use global into modules as it's forbidden into the validator.
By the way, I would prefer (and it would keep BC) keep using Tools::getValue().
Tools::getValue method would use the kernel to retrieve the request and return the needed data when we are on a symfony controller.
What do you think ?
from docs.
ping @Shudrum @julienbourdeau
from docs.
Hi Jonathan,
I think in a module, a simple Tools::getValue('id')
should do the job just fine.
We considered $request = Request::createFromGlobals()
or the snippet you sent me by email but we think there is no point. If there is no container, using the good old way is fine :)
What do you think?
Julien
from docs.
I'll reopen since it needs documentation.
from docs.
To "avoid" globals, you can use $request = Request::createFromGlobals()
instead.
The very best way would be making the request available in hooks! We'll discuss this today and we'll let you know.
Thanks for your detailed feedback.
from docs.
If i remember well, $request = Request::createFromGlobals()
does not include parameters (id of product).
About making request available in hooks, it's fine too, but if we can keep some BC using Tools::getValue()... That is fine too !
from docs.
You remember well, @prestamodule. The $idProduct will be null if you use the Request call.
from docs.
Related Issues (20)
- PS8: Document NavigationTabType with an example module
- Hook displayFooterCategory is missing
- Webservices - Add example to create a product from A to Z (categories, images, ...)
- Update description of example-modules
- Instruction on how to handle SSL config for autoupgrade module
- Bad links to theme templates HOT 1
- documentation module example produces an error HOT 3
- Few FO hooks are not listed in the dev doc HOT 7
- There are some errors between the BO and FO hooks in the dev doc HOT 2
- Module naming conventions should allow underscore HOT 2
- Adding a configuration page with Symfony forms HOT 7
- Forms subjects : simplify / refactor / re-arrange whole documentation
- Hooks in humminbird, links to the hooks documentation HOT 1
- Refactor the script to extract hooks, to ensure devdocs is up to date
- Missing documentation for hook actionAfterLoadRoutes
- Document using db through unix socket
- Cannot download language pack "en" HOT 1
- Set up PrestaShop 9 documentation branch HOT 1
- Mark documentation for PrestaShop 1.7 as not maintained HOT 1
- Write and adapt developer documentation for v9 HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from docs.