Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
14 / 14 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| PhysicalTableWidgetRenderer | |
100.00% |
13 / 13 |
|
100.00% |
2 / 2 |
5 | |
100.00% |
1 / 1 |
| supports | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
3 | |||
| render | |
100.00% |
10 / 10 |
|
100.00% |
1 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | /** @license For full copyright and license information, please see the LICENSE.md file. */ |
| 6 | |
| 7 | namespace App\Core\Grid\Widget; |
| 8 | |
| 9 | defined('AMMONLY_APP') || exit('Direct script access is forbidden.'); |
| 10 | |
| 11 | use App\Core\Engine\Domain\Model\PermissionContext; |
| 12 | use App\Core\Engine\Domain\Model\RelationGridMetadata; |
| 13 | use App\Core\Engine\Domain\Model\WidgetMetadata; |
| 14 | use Psr\Http\Message\ServerRequestInterface; |
| 15 | |
| 16 | /** |
| 17 | * Physical Table Widget Renderer. |
| 18 | * |
| 19 | * Renders database-backed physical module records (logs, audit, crud records) |
| 20 | * inside a Gridstack widget tile using metadata-driven UiType presentation. |
| 21 | * |
| 22 | * @package App\Core\Grid\Widget |
| 23 | */ |
| 24 | final readonly class PhysicalTableWidgetRenderer extends AbstractTableWidgetRenderer |
| 25 | { |
| 26 | |
| 27 | /** {@inheritdoc} */ |
| 28 | public function supports(WidgetMetadata $widget): bool |
| 29 | { |
| 30 | return $widget->name === 'physical_table' |
| 31 | || $widget->handlerClass === self::class |
| 32 | || $widget->handlerClass === 'App\\Core\\Grid\\Widget\\PhysicalTableWidgetRenderer'; |
| 33 | } |
| 34 | |
| 35 | /** {@inheritdoc} */ |
| 36 | public function render( |
| 37 | RelationGridMetadata $relation, |
| 38 | ServerRequestInterface $request, |
| 39 | PermissionContext $context |
| 40 | ): string { |
| 41 | $moduleName = (string) ($relation->widgetParams['module_name'] ?? ''); |
| 42 | if ($moduleName === '') { |
| 43 | return '<div class="alert alert-warning m-3">No module name configured in widget relation.</div>'; |
| 44 | } |
| 45 | |
| 46 | return $this->renderModuleTable( |
| 47 | $moduleName, |
| 48 | $relation, |
| 49 | $request, |
| 50 | $context, |
| 51 | 'engine/partials/widget_physical_table.twig' |
| 52 | ); |
| 53 | } |
| 54 | } |