/** * Load defined relations * @param \Spot\Entity\EntityInterface $entity * @param string $name * @param bool $reload * @return \Spot\Entity\EntityInterface * @throws \InvalidArgumentException */ public function loadRelation($entity, $name, Mapper $mapper, $reload = false) { $entityName = $entity instanceof ResultsetInterface ? $entity->getEntityName() : $entity->toString(); if (empty($entityName)) { throw new \InvalidArgumentException("Cannot load relation with a null \$entityName"); } $relations = $this->entityManager->getRelations($entityName); if (isset($relations[$name])) { return $this->loadRelationObject($entity, $name, $relations[$name], $mapper); } return $entity; }