Data Resolver
The data resolver fetches the actual content displayed inside a widget at runtime. When the
frontend requests widget data, the bundle looks up the resolver for the widget's type and
calls resolveData().
Interface
namespace Pimcore\Bundle\StudioDashboardsBundle\Resolver\Widget;
use Pimcore\Bundle\StudioDashboardsBundle\Schema\Widget\WidgetConfig;
interface DataResolverInterface
{
public function getSupportedWidgetType(): string;
public function resolveData(WidgetConfig $widget): mixed;
}
| Method | Purpose |
|---|---|
getSupportedWidgetType() | Must return the same type identifier as the matching repository and hydrator |
resolveData() | Returns the data payload for the widget; the return type is passed directly to the API response |
Example
The resolver receives the fully hydrated WidgetConfig DTO, so it has access to all stored
configuration fields (e.g. element type, page size, selected report ID).
namespace App\Widget\Resolver;
use Pimcore\Bundle\StudioDashboardsBundle\Resolver\Widget\DataResolverInterface;
use Pimcore\Bundle\StudioDashboardsBundle\Schema\Widget\WidgetConfig;
use Pimcore\Bundle\StudioDashboardsBundle\Service\Loader\Widget\TaggedIteratorDataResolver;
use Pimcore\Model\Asset;
use Symfony\Component\DependencyInjection\Attribute\AutoconfigureTag;
#[AutoconfigureTag(TaggedIteratorDataResolver::RESOLVER_TAG)]
final class TopAssetsResolver implements DataResolverInterface
{
public function getSupportedWidgetType(): string
{
return 'top_assets';
}
public function resolveData(WidgetConfig $widget): mixed
{
$list = new Asset\Listing();
$list->setOrderKey('modificationDate');
$list->setOrder('DESC');
$list->setLimit(10);
return array_map(
static fn (Asset $asset) => [
'id' => $asset->getId(),
'filename' => $asset->getFilename(),
'path' => $asset->getFullPath(),
],
$list->load()
);
}
}
The #[AutoconfigureTag(TaggedIteratorDataResolver::RESOLVER_TAG)] attribute registers the
class with the tagged-iterator loader automatically.
Permissions
If the widget data requires specific Pimcore user permissions, declare them in the
ConfigRepositoryInterface::getRequiredPermissions() method of the matching repository.
The bundle checks them before calling resolveData() and returns a 403 response if
permissions are missing.