-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
Add getParams and setParams to Magento\Framework\App\RequestInterface #865
Comments
Makes sense. I believe this interface is meant to be an abstraction layer to |
👍 |
I believe that is no reason to add a method to interface when it used in some places, because it contradicts the Interface segregation principle. Better to define dependencies on real interfaces and never use method not from interface. So better to define new interface Magento\Framework\Request with getParameter and extend Magento\Framework\App\RequestInterface from this. Also I propose to split interfaces on mutable and readonly part. For example PSR proposal for http message do not have setters for parameters. |
@kandy 👍 for specialised interfaces. IMO the |
Internal ticket: MAGETWO-32340 |
@ashsmith After a review of your proposal a pull request would be accepted. Having getParams() missing is a mistake causing us to go around the defined interface. Thanks for the suggestion and your help is appreciated. |
@TexanHogman good stuff, I'll submit the PR tomorrow then! :) |
…erface magento#865 magento#1053 Merge branch '865-add-getParams-setParams-to-request-interface' of git://github.com/ashsmith/magento2 into ashsmith-865-add-getParams-setParams-to-request-interface Conflicts: dev/tests/unit/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/SaveTest.php dev/tests/unit/testsuite/Magento/Checkout/Helper/CartTest.php dev/tests/unit/testsuite/Magento/Checkout/Model/Type/OnepageTest.php dev/tests/unit/testsuite/Magento/Customer/Controller/Account/CreateTest.php dev/tests/unit/testsuite/Magento/Customer/Controller/Account/LoginPostTest.php dev/tests/unit/testsuite/Magento/Customer/Controller/Adminhtml/Index/IndexTest.php dev/tests/unit/testsuite/Magento/Customer/Controller/Ajax/LoginTest.php dev/tests/unit/testsuite/Magento/Customer/Model/Metadata/Form/FileTest.php dev/tests/unit/testsuite/Magento/Downloadable/Controller/Adminhtml/Downloadable/Product/Edit/LinkTest.php dev/tests/unit/testsuite/Magento/Downloadable/Controller/Adminhtml/Downloadable/Product/Edit/SampleTest.php dev/tests/unit/testsuite/Magento/Downloadable/Controller/Download/LinkTest.php dev/tests/unit/testsuite/Magento/Framework/App/Action/ActionTest.php dev/tests/unit/testsuite/Magento/Framework/App/Router/NoRouteHandlerTest.php dev/tests/unit/testsuite/Magento/Framework/Controller/Result/ForwardTest.php dev/tests/unit/testsuite/Magento/Framework/UrlTest.php
…erface magento#865 magento#1053 - Remove RequestInterface::getParam from obsolete_methods since it still exists - Move getCookie to PhpEnvironment\Request
Closed. PR is merged. |
MSI-836: Merchant should see the salable qty for product in single source mode.
I have noticed in multiple places that
getParams()
is expected to be set on the request object, despite the interface not requiring thegetParams()
method. My understanding is that we're using DI and specifying the Interface, it means we shouldn't rely on methods not in the implementation interface.Adding
getParams()
toMagento\Framework\App\RequestInterface
seems like the right thing to do, and is a common method used by not only the core of Magento, but by extension developers too. I wouldn't feel comfortable using this method knowing that I can't rely on it existence.More than happy to fork, and submit a pull request but it requires a fair bit of work - so before I commit to that I'd want approval :)
By searching for
$this->getRequest()->getParams()
I was able to find 20 occurrences, 18 of which happen withapp/code/Magento/*
. This is just for controllers, I'm sure there are instances in helpers and models where getParams from the request interface is used.Thanks,
Ash Smith
The text was updated successfully, but these errors were encountered: