During the last week I finished my work on the dependency injection container and a helper for the template system. Also, the mid-term evaluation was submitted. I am grateful of being one of the PMA developers 🙂
Files Covered In This Week
Outcomes In This Week
The helper for template system & Refactor tbl_columns_definition_form.inc.php
In order to refactor tbl_columns_definition_form.inc.php, I created this helper to simplify branching and accessing array elements. By using
PMA\Util\get, it enable us access an array using dot notation. Here is an example:
$test = array('a' => array('b' => array('c')));
echo Util\get($test, 'a.b');
It will print the result below:
If the specified path or the value not exist, it will return a default value. The default value can be set as the third parameter of the function. It’s set to
null by default.
Dependency Injection Container
First I implemented the container using closures, but phpunit failed so that I can only implement a new one in class form. The dependency container is mainly use to free us from passing plenty of parameters to construct classes.
When we use the container, we can just set up some global parameters like
$GLOBAL['url_query'] in it. We can also register services or factories (
Container::service). After we finish setting up dependencies, we can construct the class by calling
Container::get and pass the rest of user-specified parameters for the class. We don’t need to worry about the long-long parameter list, since the container will resolve by itself.
What Will I Do Next
In the following 1 weeks, I will work on refining the Table class and TableSearch class.