Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
13 / 13 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| VirtualTableWidgetRenderer | |
100.00% |
12 / 12 |
|
100.00% |
2 / 2 |
8 | |
100.00% |
1 / 1 |
| supports | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
4 | |||
| render | |
100.00% |
8 / 8 |
|
100.00% |
1 / 1 |
4 | |||
| 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 | * Virtual Table Widget Renderer. |
| 18 | * |
| 19 | * Renders module tables (both virtual dynamic datasets and physical records) |
| 20 | * within a Gridstack tile container using the Central Engine pipeline. |
| 21 | * |
| 22 | * @package App\Core\Grid\Widget |
| 23 | */ |
| 24 | final readonly class VirtualTableWidgetRenderer extends AbstractTableWidgetRenderer |
| 25 | { |
| 26 | /** {@inheritdoc} */ |
| 27 | public function supports(WidgetMetadata $widget): bool |
| 28 | { |
| 29 | return $widget->name === 'virtual_table' |
| 30 | || $widget->name === 'physical_table' |
| 31 | || $widget->handlerClass === self::class |
| 32 | || $widget->handlerClass === 'App\\Core\\Grid\\Widget\\VirtualTableWidgetRenderer'; |
| 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 | $source = (string) ($relation->widgetParams['source'] ?? ''); |
| 44 | if ($source === 'composer') { |
| 45 | $moduleName = 'about_licenses'; |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | if ($moduleName === '') { |
| 50 | return '<div class="alert alert-warning m-3">No widget module configured.</div>'; |
| 51 | } |
| 52 | |
| 53 | return $this->renderModuleTable($moduleName, $relation, $request, $context); |
| 54 | } |
| 55 | } |