$propertyName instanceof Proxy) { return; } if ($this->$propertyName->__isInitialized()) { return; } // if a proxy exists (= we have related entity ID), try to load it // to see if it is a valid ID referencing an existing entity try { $this->$propertyName->__load(); } catch (EntityNotFoundException $e) { $this->$propertyName = $emptyValue; } } }