protected function registerObject(ObjectId $umi, PersistentObject $obj, $buildDepth, $varName) {
    if ($buildDepth == 0) {
      $buildDepth=BuildDepth::SINGLE;
    }
    // save the object in the session
    $umiStr = $umi->toString();
    $objects = $this->session->get($varName);
    if (!isset($objects[$umiStr])) {
      $objects[$umiStr] = [];
    }
    $objects[$umiStr][$buildDepth] = $obj;
    $this->session->set($varName, $objects);
  }