public function refresh()
{
// Several refresh() calls might happen during one request. If that is the case, the Resource Manager can't know
// that the first created resource object doesn't have to be persisted / published anymore. Thus we need to
// delete the resource manually in order to avoid orphaned resource objects:
if ($this->resource !== null) {
$this->resourceManager->deleteResource($this->resource);
}
parent::refresh();
$this->renderResource();
}