public function castLink() { if ($this->value instanceof \stdClass) { return $this->getHydrator()->hydrate($this->value); } try { return $this->getHydrator()->hydrateRid(new Rid($this->value)); } catch (ValidationException $e) { return null; } }