Get a relationship by its name, or null if no such relationship exists
public getRelationshipByName ( string $name ) : |
||
$name | string | |
return |
/** * Get the value of a property on the entity * * @param string $name * @return mixed */ public function getPropertyValue($name) { if ($column = $this->metadata->getColumnByProperty($name)) { $getter = $column->getGetter(); return $this->entity->{$getter}(); } elseif ($relationship = $this->metadata->getRelationshipByName($name)) { $getter = $relationship->getGetter(); return $this->entity->{$getter}(); } else { throw new InvalidArgumentException("No column/relationship found for property '" . $name . "'"); } }
/** * Check if $method refers to a related entity, if it does then use the EntityManager to hydrate that entity * * @param string $method * @return $this */ private function examineMethodForHydration($method) { $property = $this->metadata->getPropertyFor($method); if ($property) { $relative = $this->metadata->getRelationshipByName($property); if ($relative) { if ($relative->getSetter() == $method) { $this->proxy->setRelativeModified($property); $this->hydrated_methods[$method] = true; $this->hydrated_methods[$relative->getGetter()] = true; } elseif ($relative->getGetter() == $method) { if (!isset($this->hydrated_methods[$method])) { $this->hydrateRelative($relative); $this->hydrated_methods[$method] = true; $this->hydrated_methods[$relative->getSetter()] = true; } } } } return $this; }