Upgrading to version 5.0.x requires updating your PHP environment and refactoring several core components due to architectural improvements in aggregation, multi-action columns, and filtering.
System Requirements
- PHP Version: Upgrade from PHP 5.5+ to PHP 5.6+.
Breaking Changes
1. Trait Refactoring (High Impact)
Custom button implementations must replace the monolithic TButton trait with specific traits for icons, classes, text, and titles.
Before (v4.x):
use Ublaboo//DataGrid//Traits//TButton;
class CustomAction {
use TButton;
}
After (v5.0.x):
use Ublaboo\DataGrid\Traits\TButtonIcon;
use Ublaboo\DataGrid\Traits\TButtonClass;
use Ublaboo\DataGrid\Traits\TButtonText;
use Ublaboo\DataGrid\Traits\TButtonTitle;
class CustomAction {
use TButtonIcon, TButtonClass, TButtonText, TButtonTitle;
}
2. Method Signature Changes (Medium Impact)
If you are extending the DataGrid class, update the setDefaultSort method signature.
Before (v4.x):
public function setDefaultSort($sort)
After (v5.0.x):
public function setDefaultSort($sort, $use_on_reset = true)
3. Exception Handling (Medium Impact)
Replace generic DataGridException catches with specific exception types for better error handling.
Before (v4.x):
try {
$column = $grid->getColumn($key);
} catch (DataGridException $e) {
// handle error
}
After (v5.0.x):
try {
$column = $grid->getColumn($key);
} catch (DataGridColumnNotFoundException $e) {
// handle missing column
} catch (DataGridFilterNotFoundException $e) {
// handle missing filter
}
4. Method Name Corrections (Low Impact)
Fix the typo in the session management method.
- Old:
$grid->deleteSesssionData($key); - New:
$grid->deleteSessionData($key);
Migration Steps
- Update PHP version to 5.6+.
- Replace
TButton trait with specific button traits in custom action classes. - Update exception handling to catch
DataGridColumnNotFoundException and DataGridFilterNotFoundException. - Update
setDefaultSort() signatures if extending the class. - Fix the
deleteSessionData() typo. - Thoroughly test all existing functionality.
// Example of the new trait usage in v5.0.x
use Ublaboo\DataGrid\Traits\TButtonIcon;
use Ublaboo\DataGrid\Traits\TButtonClass;
use Ublaboo\DataGrid\Traits\TButtonText;
use Ublaboo\DataGrid\Traits\TButtonTitle;
class CustomAction {
use TButtonIcon, TButtonClass, TButtonText, TButtonTitle;
}