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
External dependency injection system #15266
Conversation
Great idea. As I said in #15248 (comment), I also want to improve how we handle request and response with a HTTP library. |
|
If you find any bug to fix or any code to improve, please tell me, I'll do my best to do it. |
|
Hi,
This variable is defined in Thank you. |
The static analyzer doesn't know about variables defined in another files. We have been ignoring these errors. Line 18 in 720e302
|
|
Some ways to solve this would be to get the variable some other way, or if it is a global variable, declare it in the file. |
Yes, I know this is done for other variables. But doing this would encourage use of the container through the global variable in many places, whereas the idea would rather be to provide the data as an input. |
No problem. |
|
Please don't merge it for now, I've an error after the creation of a table. |
Please ignore my previous message, it was on the other PR I'm working on. |
ajax.php
Outdated
| $GLOBALS['PMA_Config'] | ||
| ); | ||
| /** @var AjaxController $controller */ | ||
| $controller = $containerBuilder->get('ajax_controller'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about using AjaxController::class instead of 'ajax_controller'?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is OK for me. I'll rename the controller services with the class name of the controllers.
Codecov Report
@@ Coverage Diff @@
## master #15266 +/- ##
============================================
- Coverage 52.82% 52.8% -0.03%
Complexity 14059 14059
============================================
Files 484 484
Lines 62163 62198 +35
============================================
+ Hits 32840 32841 +1
- Misses 29323 29357 +34 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good work!
|
|
||
| if (! defined('ROOT_PATH')) { | ||
| define('ROOT_PATH', __DIR__ . DIRECTORY_SEPARATOR); | ||
| } | ||
|
|
||
| require_once ROOT_PATH . 'libraries/common.inc.php'; | ||
|
|
||
| $response = $containerBuilder->get('response', ContainerInterface::NULL_ON_INVALID_REFERENCE) ?? Response::getInstance(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you use ::class ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I defined response as a service in the other PR, I would like to do it in the other one if this is OK for you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent work!
|
@Tithugues Do you think it's now possible to remove our custom DIC ( |
Not yet. But I should confess this is one on my aims…
When all the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💯
|
Do you want me to squash the commits before merging the branch? |
|
You can do it, if you want. |
Signed-off-by: Hugues Peccatte <hugues.peccatte@gmail.com>
|
Done. |
|
There are a few Selenium errors. You can open the link in the log to see the video of the test. https://travis-ci.org/phpmyadmin/phpmyadmin/jobs/534311833#L494 |
Signed-off-by: Hugues Peccatte <hugues.peccatte@gmail.com>
Thanks, I did some fixes. I'll wait for Selenium feedback. |
|
Excellent work! Thank you for your contribution. |
External dependency injection system [ci skip] Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
External dependency injection system [ci skip] Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev> Signed-off-by: Nupur Agrawal <nupur202000@gmail.com>
Description
What do you think about this kind of DI system please?
The current system seems to be restrictive: the definition of services should be done in PHP (which doesn't seem very readable for me), also the parameters can't be defined at the beginning (only when getting the object).
With this system, we defined the template class and it can be passed everywhere quite easily, and this may be done for other classes. Also in a second step, this would enforce the principle to use injection instead of building objects in other objects. (I would love to split the current
Responseclass inHtmlResponseandAjaxResponseclasses with a commonResponseInterface.)Fixes #
Before submitting pull request, please review the following checklist:
Signed-off-byline as described in our DCO. This ensures that the work you're submitting is your own creation.