ATK team is excited to announce availability of 2.1 branches across core ATK repositories. This release is primarily focused on clean-ups and optimisation in our 2.x branch. This article will highlight some of the more exciting new additions:
Changes to Versioning
I already have discussed details here: IMPORTANT: New Release Mechanics
New UI Demo Navigation and interactive Demo
Our demo-site (https://ui.agiletoolkit.org) has been showcasing 1.7 version of ATK UI and we couldn’t update it to 2.0 due to hosting issues. This has been addressed now and you should see up-to-date version of ATK UI.
There is also new navigation (number of pages have been getting too long) and we’ve added “Demos” - interactive multi-step wizards to specifically take you through a specific set of features.
If you haven’t had an opportunity to look into “User Actions” the wizard will take you through some of the key points.
New default initializer “addTo()” for better type hinting
For a long time we used add() method to initialize children in UI and elsewhere in ATK. We are introducing alternative syntax - addTo which has better type hinting:
// old $button = $page->add(['Button', 'Click Me']); $button->icon.. // will appear as warning in IDE, because add() returns View class // new format $button = Button::addTo($page, ['Click Me']); $button->icon.. // will type-hint correctly because Button::addTo returns @self
Because this is a huge change, we will keep add() compatibility for all of 2.x releases of ATK (or longer). No need to refactor this code, however we have updated all demos and examples to use a new format.
Unified and improved Unit Testing system
The build engine for all repositories has been revamped and we have adopted PSR-12 standard. As a result - lot of cosmetic changes and much faster build times! We are now including CS Fixer too and it’s recommended for all ATK repositories and plugins.
Migrating to 2.1 and potential BC break summary
- Persistence::$driver property has been renamed to Persistence::$driverType. This can have values such as“mysql”, “oci”, “sqlite” and more (atk4/schema is updated accordingly)
- ATK gradually introduces more type-hinting, so if your code have been extending any of the core classes and overriding, you may need to make sure your function definition is compatible.
- If you were extending “PHPUnit7_AgileTestCase” in your unit tests - replace it with“atk4\core\AtkPhpunit\TestCase”.
- If you are using “ConfigTrait” with a format “php-inline” replace it with “php”, which now will always return config.
- Classes “Persistence_Array”, “Persistence_SQL”, “Reference_Many” and some other classes with underscores have been deprecated in 2.0 are now removed.
Hook breaker class
Currently you can break out of hooks and even pass some information, which will then be returned by hook() method. Version 2.1 can now output hook breaker object too. This is convenient if you have multiple callbacks registered by multiple objects and you wish to learn which one broke the hook.
Models to Model joins support with addWith()
Model introduces setNull() for all field types
There are two flags for model field - mandatory and required. You can read more about them in the documentation. Those flags prevent you from setting
New and improved elements
We have introduced the following new or improved UI elements:
- DropDownCascade offers multiple cascaded DropDowns which show filtered, cascaded results based on the parent DropDown (e.g., Country > District > City).
- Maestro layout is an improvement of the Admin layout with the possibility to collapse or expand left menu groups and their items.
- ActionModal windows can now be easily configured in size by e.g. $grid->addModalAction([‘icon’=>‘user edit’],[‘class’ => [‘tiny’]],…
PRs with significant BC-break:
- https://github.com/atk4/core/pull/133/files#diff-08f44384ad9646881f3b84d38f3e8d92R46 different return type, more strict method header
- https://github.com/atk4/core/pull/162/files#diff-5e6bff90043b25119e765928c605fc82R10 renamed TestCase class/NS
- https://github.com/atk4/core/pull/182/files#diff-0465835788d64e7f6e72e370ba840cfaR85 no action needs to be normally taken
- https://github.com/atk4/core/pull/198/files#diff-ed6dfe79d5db5fd0d2335ff771b8513eR63 (always return in PHP config, “php-inline” is renamed to “php”)
- https://github.com/atk4/data/pull/553/files#diff-01b38558f57cb95e26594f32451b271eL23 refactored “driver” to“driverType” property
- https://github.com/atk4/data/pull/552 removed deprecated classes from 1.x
- https://github.com/atk4/ui/pull/1051 , https://github.com/atk4/ui/pull/1065 output and headers are redesigned and more strict/checked
- https://github.com/atk4/ui/pull/1083 disable caching by default
- https://github.com/atk4/ui/pull/1089 methods headers init(), setDefaults(), normalizeClassNameApp() changed
PRs with other significant changes:
- CS/IMPROVE https://github.com/atk4/core/pull/175/files#diff-8b6c0c683d533f32b31ce28cee1bd3e6R3 add strict CS fixer and largely improved unit testing thru GH actions (use this as a template in other repos)
- NEW https://github.com/atk4/core/pull/187
- NEW https://github.com/atk4/core/blob/develop/src/StaticAddToTrait.php#L10 , https://github.com/atk4/ui/pull/929 , https://github.com/atk4/ui/pull/991 added “StaticAddToTrait” trait, very helpful for refactorablility, see ui for usage
- CS/internal https://github.com/atk4/ui/pull/888 use “\n” as NL in every file and always terminate with one EOL
- NEW https://github.com/atk4/data/pull/527 add WITH SQL support
- NEW https://github.com/atk4/data/pull/569 add setNull() to set field value to NULL even if NULL is not allowed by field definition
- UX https://github.com/atk4/ui/pull/1078 , https://github.com/atk4/ui/pull/1082 , https://github.com/atk4/ui/pull/1193 render all Throwable thru nice Atk exception renderer
- NEW https://github.com/atk4/ui/pull/1137 better style/script escaping, use it if you did not used it before bacause of this
For full list of changes: https://github.com/atk4/ui/releases/tag/2.1.0