protected function loadLinkFields(Entity $entity) { $fieldDefs = $this->getMetadata()->get('entityDefs.' . $entity->getEntityType() . '.fields', array()); $linkDefs = $this->getMetadata()->get('entityDefs.' . $entity->getEntityType() . '.links', array()); foreach ($fieldDefs as $field => $defs) { if (isset($defs['type']) && $defs['type'] === 'link') { if (!empty($defs['noLoad'])) { continue; } if (empty($linkDefs[$field])) { continue; } if (empty($linkDefs[$field]['type'])) { continue; } if ($linkDefs[$field]['type'] !== 'hasOne') { continue; } $entity->loadLinkField($field); } } }