-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Urlrewrite module refactoring? #1296
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
Comments
You're right, From modularity perspective:
Approach to controller action refactoring you described looks good to me 👍 : |
Hi Marius, very good catch. Url rewrites modularity definitely makes sense, and we have added that to our internal backlog MAGETWO-38050. However, we don't plan to work on that in the nearest time, so if you would like to contribute with such change, we would highly appreciate that. |
@eleonova I will try to do something, but I can't promise anything. it's kind of a big task for my current knowledge of Magento2. |
I've created a PR for this: #1338. |
Hi @tzyganu , issue was fixed, please check it, and if you think that not, feel free to write here or to open new one |
@vzabaznov WooHoo. Thanks for this. I will take a look. |
- Merge Pull Request magento-engcom/magento2ce#1296 from magento-engcom-team/magento2:batch-11-forwardport-2.3-develop - Merged commits: 1. aefd089 2. 0c799d2 3. 0a28295 4. d0d8d03 5. 1623007 6. 64f63b3 7. eceb5eb 8. e1db353 9. 7b12d50 10. 60285c4 11. 2d910df 12. 57c355a 13. 4f9f40e 14. ebd663b 15. bdb62bb 16. 76f6eed 17. cd5c72e 18. b035660 19. 6217c00 20. e07d040 21. 47ea318
This is more of a question and a personal oppinion than an issue, but it can be an issue if you want it to be 😄
Right now the url rewrites are kind of limited to products, categories and cms pages and it makes really hard to extend the functionality to custom entities.
Let's take this example to make it clearer
Magento\UrlRewrite\Controller\Adminhtml\Url\Rewrite\Edit::execute()
Notice the ugly
switch-case
statementsSure I can do an
around
interceptor on it to plugin my own entity, but that's dangerous and I would rather avoid it.But even if I do that then there is the
_getMode()
method in the same class that's protected, so... "no interceptors for you".Notice the
if-elseif
chain even uglier than theswitch-case
statements.This means I have to add a preference for this class so I can use mine. What If there are 2 or more custom entities that want url rewrite?
I think a cleaner way of doing it would be through
di.xml
. Have a general classEdit
that can receive as parameters the modes and the blocks needed for each mode (and other data that might be needed). This way the catalog related url rewrites actions and blocks can be moved toCatalogUrlRewrite
module, cms related actions can be moved toCmsUrlRewrite
and I can create my own extension calledSuperAwesome
and have a second one calledSuperAwesomeUrlRewrite
to link my entity to url rewrites.Care to comment on this? I would really like to hear your thoughts about the url rewrites.
The text was updated successfully, but these errors were encountered: