/** * Get Links object associated with this model. * If there is none, an empty Links object is created. * * @param AbstractModel $model * @return Links * @throws InvalidArgumentException If model does not belong to repo */ public function get(AbstractModel $model) { if (!$this->repo->isModel($model)) { throw new InvalidArgumentException(sprintf('Model must be %s, was %s', $this->repo->getModelClass(), get_class($model))); } if ($this->map->contains($model)) { return $this->map[$model]; } else { return $this->map[$model] = new Links($model); } }